@progress/kendo-react-conversational-ui 11.4.0-develop.8 → 11.4.0
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/README.md +80 -23
- package/ai-prompt/AIPrompt.js +1 -1
- package/ai-prompt/AIPrompt.mjs +37 -35
- package/ai-prompt/views/AIPromptView.js +2 -2
- package/ai-prompt/views/AIPromptView.mjs +48 -53
- package/ai-prompt/views/constants.js +1 -1
- package/ai-prompt/views/constants.mjs +1 -1
- package/chat/components/SuggestionsGroup.js +1 -1
- package/chat/components/SuggestionsGroup.mjs +12 -10
- package/dist/cdn/js/kendo-react-conversational-ui.js +1 -1
- package/index.d.mts +14 -0
- package/index.d.ts +14 -0
- package/inline-ai-prompt/InlineAIPrompt.js +1 -1
- package/inline-ai-prompt/InlineAIPrompt.mjs +100 -100
- package/package-metadata.js +1 -1
- package/package-metadata.mjs +4 -4
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -1,31 +1,88 @@
|
|
|
1
|
-
[](https://www.telerik.com/kendo-react-ui/components/free?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-
|
|
1
|
+
[](https://www.telerik.com/kendo-react-ui/components/free?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-conversational-ui&utm_content=banner)
|
|
2
2
|
|
|
3
|
-
# KendoReact
|
|
3
|
+
# KendoReact Conversational UI Library for React
|
|
4
4
|
|
|
5
5
|
> **Important**
|
|
6
6
|
>
|
|
7
|
-
> - This package is а part of [KendoReact](https://www.telerik.com/kendo-react-ui?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-
|
|
7
|
+
> - This package is а part of [KendoReact](https://www.telerik.com/kendo-react-ui?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-conversational-ui)—an enterprise-grade UI library with 120+ free and premium components.
|
|
8
8
|
> - To use this package, you must install a license key file, whether you are on a paid license or a 30-day free trial. To receive a license key, either [purchase a license](https://www.telerik.com/kendo-react-ui/pricing) or start a [free trial](https://www.telerik.com/download-login-v2-kendo-react-ui).
|
|
9
|
-
> - It provides premium KendoReact components and features. You will need to install a license key when adding the package to your project. For more information, please refer to the [KendoReact My License page](https://www.telerik.com/kendo-react-ui/components/my-license/?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-
|
|
10
|
-
> - To receive a license key, you need to either [purchase a license](https://www.telerik.com/kendo-react-ui/pricing?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-
|
|
9
|
+
> - It provides premium KendoReact components and features. You will need to install a license key when adding the package to your project. For more information, please refer to the [KendoReact My License page](https://www.telerik.com/kendo-react-ui/components/my-license/?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-conversational-ui).
|
|
10
|
+
> - To receive a license key, you need to either [purchase a license](https://www.telerik.com/kendo-react-ui/pricing?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-conversational-ui) or register for a [free trial](https://www.telerik.com/try/kendo-react-ui?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-conversational-ui). Doing so indicates that you [accept the KendoReact License Agreement](https://www.telerik.com/purchase/license-agreement/progress-kendoreact?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-conversational-ui).
|
|
11
11
|
> - The 30-day free trial gives you access to all KendoReact components and their full functionality. Additionally, for the period of your trial, you can use our legendary technical support provided directly by the KendoReact dev team!
|
|
12
12
|
>
|
|
13
|
-
> [Start using KendoReact](https://www.telerik.com/try/kendo-react-ui?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-
|
|
13
|
+
> [Start using KendoReact](https://www.telerik.com/try/kendo-react-ui?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-conversational-ui) and speed up your development process!
|
|
14
14
|
>
|
|
15
15
|
> If you're looking for free React components, check out [Get Started with KendoReact Free](https://www.telerik.com/kendo-react-ui/components/free).
|
|
16
16
|
|
|
17
|
-
The
|
|
17
|
+
The KendoReact Conversational UI library provides a set of React components—such as Chat, AIPrompt, and InlineAIPrompt—that enable you to build modern conversational experiences, including chat interfaces, AI-powered prompts, and seamless user interactions with both humans and bots.
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
How to start:
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
```sh
|
|
22
|
+
npm i @progress/kendo-react-conversational-ui
|
|
23
|
+
```
|
|
22
24
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
- [
|
|
26
|
-
- [
|
|
27
|
-
- [
|
|
28
|
-
- [
|
|
25
|
+
What's in this package:
|
|
26
|
+
|
|
27
|
+
- [React Conversational UI Components Library Features](#react-conversational-ui-components-library-features)
|
|
28
|
+
- [React AIPrompt Component (premium)](#react-aiprompt-component)
|
|
29
|
+
- [React Chat Component (premium)](#react-chat-component)
|
|
30
|
+
- [React InlineAIPrompt Component (premium)](#react-inlineaiprompt-component)
|
|
31
|
+
|
|
32
|
+
Additional information:
|
|
33
|
+
|
|
34
|
+
- [Support Options](#support-options)
|
|
35
|
+
- [Resources](#resources)
|
|
36
|
+
- [KendoReact Conversational UI API](https://www.telerik.com/kendo-react-ui/components/conversationalui/api)
|
|
37
|
+
|
|
38
|
+
## React Conversational UI Components Library Features
|
|
39
|
+
|
|
40
|
+
Among the many features which the KendoReact Conversational UI components deliver are:
|
|
41
|
+
|
|
42
|
+
- **Accessibility support**—The Conversational UI components are compliant with WAI-ARIA and Section 508.
|
|
43
|
+
- **Keyboard navigation**—All components provide comprehensive keyboard navigation support.
|
|
44
|
+
- **Globalization**—The Conversational UI components come with globalization features that allow you to create applications that can be used all over the world.
|
|
45
|
+
- [**Theme support**](https://www.telerik.com/kendo-react-ui/components/styling/?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-conversational-ui)—The KendoReact Conversational UI components, as well as all 120+ components in the KendoReact suite, are styled in three polished themes (Bootstrap, Material, and Default) and can be further customized to match your specific design guidelines.
|
|
46
|
+
|
|
47
|
+
## React AIPrompt Component
|
|
48
|
+
|
|
49
|
+
> This is a KendoReact **premium component** and requires a commercial license or an active trial license.
|
|
50
|
+
|
|
51
|
+
[The KendoReact AIPrompt component](https://www.telerik.com/kendo-react-ui/components/conversationalui/ai-prompt?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-conversational-ui) enables you to add AI-driven prompt capabilities to your applications. It is designed to facilitate user interactions with AI models, allowing for dynamic suggestions, completions, or contextual assistance. The component can be integrated with various AI services and customized to fit your application's needs, supporting features like streaming responses, custom views, and prompt commands.
|
|
52
|
+
|
|
53
|
+
Key features include:
|
|
54
|
+
|
|
55
|
+
- [**Suggestions**](https://www.telerik.com/kendo-react-ui/components/conversationalui/ai-prompt/suggestions/?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-conversational-ui)—Create custom prompt suggestions to guide user interactions.
|
|
56
|
+
- [**Streaming responses**](https://www.telerik.com/kendo-react-ui/components/conversationalui/ai-prompt/streaming/?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-conversational-ui)—Display AI responses progressively as they are generated in real-time.
|
|
57
|
+
- [**Custom commands**](https://www.telerik.com/kendo-react-ui/components/conversationalui/ai-prompt/commands/?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-conversational-ui)—Define custom prompt commands for specialized AI interactions.
|
|
58
|
+
- [**Customization options**](https://www.telerik.com/kendo-react-ui/components/conversationalui/ai-prompt/customization/?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-conversational-ui)—Customize component appearance and behavior to match your application needs.
|
|
59
|
+
- [**Events support**](https://www.telerik.com/kendo-react-ui/components/conversationalui/ai-prompt/events/?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-conversational-ui)—Handle various user interactions and AI response events.
|
|
60
|
+
|
|
61
|
+
## React Chat Component
|
|
62
|
+
|
|
63
|
+
> This is a KendoReact **premium component** and requires a commercial license or an active trial license.
|
|
64
|
+
|
|
65
|
+
[The KendoReact Chat component](https://www.telerik.com/kendo-react-ui/components/conversationalui/chat?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-conversational-ui) bridges the gap between the Web and the next-generation natural language applications and delivers a Chat component which allows the user to participate in chat sessions with other users or with chat bots. The component provides integration options for connecting to chat bots built with Google DialogFlow, Microsoft Bot Framework, and many others.
|
|
66
|
+
|
|
67
|
+
Key features include:
|
|
68
|
+
|
|
69
|
+
- [**Data binding**](https://www.telerik.com/kendo-react-ui/components/conversationalui/chat/data-binding/?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-conversational-ui)—Bind the message list to streaming data from remote services and automated responses.
|
|
70
|
+
- [**Suggested actions**](https://www.telerik.com/kendo-react-ui/components/conversationalui/chat/suggested-actions/?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-conversational-ui)—Display quick action buttons like preset replies for enhanced user experience.
|
|
71
|
+
- [**Message attachments**](https://www.telerik.com/kendo-react-ui/components/conversationalui/chat/attachments/?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-conversational-ui)—Support for attaching images, videos, or data to chat messages.
|
|
72
|
+
- [**Message templates**](https://www.telerik.com/kendo-react-ui/components/conversationalui/chat/message-templates/?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-conversational-ui)—Customize the appearance of chat messages using templates.
|
|
73
|
+
- [**Bot integrations**](https://www.telerik.com/kendo-react-ui/components/conversationalui/chat/integrations/dialogflow/?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-conversational-ui)—Integration with Google DialogFlow, Microsoft Bot Framework, and other chatbot services.
|
|
74
|
+
|
|
75
|
+
## React InlineAIPrompt Component
|
|
76
|
+
|
|
77
|
+
> This is a KendoReact **premium component** and requires a commercial license or an active trial license.
|
|
78
|
+
|
|
79
|
+
[The KendoReact InlineAIPrompt component](https://www.telerik.com/kendo-react-ui/components/conversationalui/inline-ai-prompt?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-conversational-ui) allows you to embed AI prompts seamlessly within chat messages or conversational flows. This enables users to interact with AI suggestions or actions directly in the context of their ongoing conversation, enhancing the user experience and streamlining workflows. The component can be integrated within existing chat interfaces to provide contextual AI assistance.
|
|
80
|
+
|
|
81
|
+
Key features include:
|
|
82
|
+
|
|
83
|
+
- [**Commands**](https://www.telerik.com/kendo-react-ui/components/conversationalui/inline-ai-prompt/commands/?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-conversational-ui)—Create custom commands and output actions for specialized AI interactions.
|
|
84
|
+
- [**Customization**](https://www.telerik.com/kendo-react-ui/components/conversationalui/inline-ai-prompt/customization/?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-conversational-ui)—Customize components to fit your application's specific requirements.
|
|
85
|
+
- **Streaming support**—Real-time AI response streaming for immediate feedback.
|
|
29
86
|
|
|
30
87
|
## Using for Free vs Commercial License
|
|
31
88
|
|
|
@@ -53,15 +110,15 @@ For any issues you might encounter while working with the KendoReact Chat, use a
|
|
|
53
110
|
|
|
54
111
|
## Resources
|
|
55
112
|
|
|
56
|
-
- [Getting Started with KendoReact](https://www.telerik.com/kendo-react-ui/components/getting-started/?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-
|
|
113
|
+
- [Getting Started with KendoReact](https://www.telerik.com/kendo-react-ui/components/getting-started/?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-conversational-ui)
|
|
57
114
|
- [Get Started with KendoReact Free](https://www.telerik.com/kendo-react-ui/components/free)
|
|
58
|
-
- [Get Started with KendoReact
|
|
59
|
-
- [API Reference of the KendoReact
|
|
60
|
-
- [KendoReact Roadmap](https://www.telerik.com/support/whats-new/kendo-react-ui/roadmap?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-
|
|
61
|
-
- [Blogs](https://www.telerik.com/blogs/tag/kendoreact?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-
|
|
62
|
-
- [Demos, documentation, and component reference](https://www.telerik.com/kendo-react-ui/components/?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-
|
|
63
|
-
- [KendoReact pricing and licensing](https://www.telerik.com/kendo-react-ui/pricing?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-
|
|
64
|
-
- [Changelog](https://www.telerik.com/kendo-react-ui/components/changelogs/ui-for-react/?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-
|
|
115
|
+
- [Get Started with KendoReact Conversational UI](https://www.telerik.com/kendo-react-ui/components/conversationalui/?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-conversational-ui)
|
|
116
|
+
- [API Reference of the KendoReact Conversational UI](https://www.telerik.com/kendo-react-ui/components/conversationalui/api/?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-conversational-ui)
|
|
117
|
+
- [KendoReact Roadmap](https://www.telerik.com/support/whats-new/kendo-react-ui/roadmap?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-conversational-ui)
|
|
118
|
+
- [Blogs](https://www.telerik.com/blogs/tag/kendoreact?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-conversational-ui)
|
|
119
|
+
- [Demos, documentation, and component reference](https://www.telerik.com/kendo-react-ui/components/?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-conversational-ui)
|
|
120
|
+
- [KendoReact pricing and licensing](https://www.telerik.com/kendo-react-ui/pricing?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-conversational-ui)
|
|
121
|
+
- [Changelog](https://www.telerik.com/kendo-react-ui/components/changelogs/ui-for-react/?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-conversational-ui)
|
|
65
122
|
|
|
66
123
|
High-level component overview pages
|
|
67
124
|
|
package/ai-prompt/AIPrompt.js
CHANGED
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),E=require("./AIPromptHeader.js"),r=require("./views/constants.js"),b=require("./AIPromptContext.js"),t=require("@progress/kendo-react-common"),n=require("../package-metadata.js"),x=i=>{const m=!t.validatePackage(n.packageMetadata,{component:"AIPrompt"}),l=t.getLicenseMessage(n.packageMetadata),{activeView:o,toolbarItems:p,children:u,onActiveViewChange:c,onPromptRequest:d,onCommandExecute:g,style:v,dir:P,className:w,streaming:k,loading:A,onCancel:I,suggestionsView:a,...S}=i,q=p||[r.promptViewDefaults,r.outputViewDefaults],[C,V]=e.useState({activeView:o}),s={...C,activeView:o,streaming:k,loading:A,suggestionsView:a!=null?a:"classic",onCancel:I,onActiveViewChange:c,onPromptRequest:d,onCommandExecute:g},h=M=>{V(M)};return e.createElement(b.AIPromptContext.Provider,{value:[s,h]},e.createElement("div",{className:t.classNames("k-prompt",w),style:v,dir:P,...S},e.createElement(E.PromptHeader,{activeView:s.activeView,toolbarItems:q,activeViewChange:c}),u,m&&e.createElement(t.WatermarkOverlay,{message:l})))};exports.AIPrompt=x;
|
package/ai-prompt/AIPrompt.mjs
CHANGED
|
@@ -6,47 +6,49 @@
|
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
8
|
import e from "react";
|
|
9
|
-
import { PromptHeader as
|
|
10
|
-
import { promptViewDefaults as
|
|
11
|
-
import { AIPromptContext as
|
|
12
|
-
import { validatePackage as
|
|
13
|
-
import { packageMetadata as
|
|
14
|
-
const
|
|
15
|
-
const m = !
|
|
16
|
-
activeView:
|
|
17
|
-
toolbarItems:
|
|
18
|
-
children:
|
|
9
|
+
import { PromptHeader as E } from "./AIPromptHeader.mjs";
|
|
10
|
+
import { promptViewDefaults as I, outputViewDefaults as x } from "./views/constants.mjs";
|
|
11
|
+
import { AIPromptContext as L } from "./AIPromptContext.mjs";
|
|
12
|
+
import { validatePackage as M, getLicenseMessage as N, classNames as b, WatermarkOverlay as y } from "@progress/kendo-react-common";
|
|
13
|
+
import { packageMetadata as s } from "../package-metadata.mjs";
|
|
14
|
+
const O = (c) => {
|
|
15
|
+
const m = !M(s, { component: "AIPrompt" }), n = N(s), {
|
|
16
|
+
activeView: a,
|
|
17
|
+
toolbarItems: i,
|
|
18
|
+
children: l,
|
|
19
19
|
onActiveViewChange: o,
|
|
20
|
-
onPromptRequest:
|
|
21
|
-
onCommandExecute:
|
|
22
|
-
style:
|
|
23
|
-
dir:
|
|
24
|
-
className:
|
|
25
|
-
streaming:
|
|
26
|
-
loading:
|
|
27
|
-
onCancel:
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
20
|
+
onPromptRequest: p,
|
|
21
|
+
onCommandExecute: d,
|
|
22
|
+
style: g,
|
|
23
|
+
dir: u,
|
|
24
|
+
className: v,
|
|
25
|
+
streaming: f,
|
|
26
|
+
loading: w,
|
|
27
|
+
onCancel: P,
|
|
28
|
+
suggestionsView: t,
|
|
29
|
+
...V
|
|
30
|
+
} = c, h = i || [I, x], [S, k] = e.useState({ activeView: a }), r = {
|
|
31
|
+
...S,
|
|
32
|
+
activeView: a,
|
|
33
|
+
streaming: f,
|
|
34
|
+
loading: w,
|
|
35
|
+
suggestionsView: t != null ? t : "classic",
|
|
36
|
+
onCancel: P,
|
|
35
37
|
onActiveViewChange: o,
|
|
36
|
-
onPromptRequest:
|
|
37
|
-
onCommandExecute:
|
|
38
|
-
},
|
|
39
|
-
|
|
38
|
+
onPromptRequest: p,
|
|
39
|
+
onCommandExecute: d
|
|
40
|
+
}, A = (C) => {
|
|
41
|
+
k(C);
|
|
40
42
|
};
|
|
41
|
-
return /* @__PURE__ */ e.createElement(
|
|
42
|
-
|
|
43
|
+
return /* @__PURE__ */ e.createElement(L.Provider, { value: [r, A] }, /* @__PURE__ */ e.createElement("div", { className: b("k-prompt", v), style: g, dir: u, ...V }, /* @__PURE__ */ e.createElement(
|
|
44
|
+
E,
|
|
43
45
|
{
|
|
44
|
-
activeView:
|
|
45
|
-
toolbarItems:
|
|
46
|
+
activeView: r.activeView,
|
|
47
|
+
toolbarItems: h,
|
|
46
48
|
activeViewChange: o
|
|
47
49
|
}
|
|
48
|
-
),
|
|
50
|
+
), l, m && /* @__PURE__ */ e.createElement(y, { message: n })));
|
|
49
51
|
};
|
|
50
52
|
export {
|
|
51
|
-
|
|
53
|
+
O as AIPrompt
|
|
52
54
|
};
|
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),y=require("../AIPromptContent.js"),j=require("../AIPromptFooter.js"),
|
|
9
|
-
`);return
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),y=require("../AIPromptContent.js"),j=require("../AIPromptFooter.js"),h=require("@progress/kendo-react-buttons"),i=require("@progress/kendo-react-inputs"),F=require("@progress/kendo-svg-icons"),I=require("@progress/kendo-react-common"),G=require("./AIPromptViewRender.js"),O=require("../AIPromptExpander.js"),z=require("../AIPromptContext.js"),M=require("../../chat/components/SuggestionsGroup.js"),W=require("./constants.js"),D=x=>{const{promptInput:A=i.TextArea,generateButton:f=h.Button,enableSpeechToText:n=!1,promptValue:S,promptSuggestions:l}=x,[s,c]=e.useState(S||""),[o]=z.useAIPromptContext(),[C,p]=I.useCustomComponent(f),[q,m]=I.useCustomComponent(A),E=()=>{o.onPromptRequest&&o.onPromptRequest.call(null,s),c("")},T=t=>{c(t)},R=t=>{c(t.target.value)},k={title:"Generate",children:"Generate",svgIcon:F.sparklesIcon},V={placeholder:"Ask or generate content with AI ...",rows:2},g=Object.keys(p).length>0?p:k,w=Object.keys(m).length>0?m:V,d=t=>{const{isFinal:r,alternatives:P}=t;if(r&&P.length>0){const b=P[0].transcript,v=(()=>{const a=s,B=a&&!a.endsWith(" ")&&!a.endsWith(`
|
|
9
|
+
`);return a+(B?" ":"")+b})();c(v)}};let u;return n&&(typeof n=="object"?u={...n,onResult:n.onResult||d}:u={onResult:d}),e.createElement(G.AIPromptViewRender,{name:W.promptViewDefaults.name},e.createElement(y.AIPromptContent,{streaming:o.streaming,onCancel:o.onCancel},e.createElement(q,{value:s,className:"!k-flex-col",suffix:n?e.createElement(e.Fragment,null,e.createElement(i.InputSeparator,{orientation:"horizontal"}),e.createElement(i.InputSuffix,{orientation:"horizontal"},e.createElement(h.SpeechToTextButton,{fillMode:"flat",...u}))):void 0,onChange:R,...w}),l&&l.length>0&&e.createElement(O.AIPromptExpander,{title:"Prompt Suggestions"},e.createElement(M.SuggestionGroup,{suggestionsView:o.suggestionsView,suggestions:l.map((t,r)=>({id:r,text:t,description:t})),onSuggestionClick:(t,r)=>{T(r.text)}}))),e.createElement(j.AIPromptFooter,null,e.createElement(C,{themeColor:"primary",fillMode:"solid",rounded:"full",size:"medium",onClick:E,disabled:!s.trim(),...g},g.children)))};exports.AIPromptView=D;
|
|
@@ -9,92 +9,87 @@ import e from "react";
|
|
|
9
9
|
import { AIPromptContent as B } from "../AIPromptContent.mjs";
|
|
10
10
|
import { AIPromptFooter as y } from "../AIPromptFooter.mjs";
|
|
11
11
|
import { SpeechToTextButton as j, Button as q } from "@progress/kendo-react-buttons";
|
|
12
|
-
import { InputSuffix as
|
|
13
|
-
import { sparklesIcon as
|
|
14
|
-
import { useCustomComponent as
|
|
15
|
-
import { AIPromptViewRender as
|
|
16
|
-
import { AIPromptExpander as
|
|
17
|
-
import { useAIPromptContext as
|
|
18
|
-
import { SuggestionGroup as
|
|
19
|
-
import { promptViewDefaults as
|
|
20
|
-
const
|
|
12
|
+
import { InputSeparator as z, InputSuffix as F, TextArea as G } from "@progress/kendo-react-inputs";
|
|
13
|
+
import { sparklesIcon as O } from "@progress/kendo-svg-icons";
|
|
14
|
+
import { useCustomComponent as d } from "@progress/kendo-react-common";
|
|
15
|
+
import { AIPromptViewRender as _ } from "./AIPromptViewRender.mjs";
|
|
16
|
+
import { AIPromptExpander as M } from "../AIPromptExpander.mjs";
|
|
17
|
+
import { useAIPromptContext as W } from "../AIPromptContext.mjs";
|
|
18
|
+
import { SuggestionGroup as $ } from "../../chat/components/SuggestionsGroup.mjs";
|
|
19
|
+
import { promptViewDefaults as D } from "./constants.mjs";
|
|
20
|
+
const oe = (h) => {
|
|
21
21
|
const {
|
|
22
|
-
promptInput: x =
|
|
22
|
+
promptInput: x = G,
|
|
23
23
|
generateButton: P = q,
|
|
24
24
|
enableSpeechToText: o = !1,
|
|
25
|
-
promptValue:
|
|
26
|
-
promptSuggestions:
|
|
27
|
-
} = h, [
|
|
28
|
-
|
|
29
|
-
},
|
|
30
|
-
|
|
31
|
-
},
|
|
32
|
-
|
|
33
|
-
},
|
|
25
|
+
promptValue: S,
|
|
26
|
+
promptSuggestions: i
|
|
27
|
+
} = h, [s, l] = e.useState(S || ""), [n] = W(), [A, c] = d(P), [E, p] = d(x), I = () => {
|
|
28
|
+
n.onPromptRequest && n.onPromptRequest.call(null, s), l("");
|
|
29
|
+
}, T = (t) => {
|
|
30
|
+
l(t);
|
|
31
|
+
}, C = (t) => {
|
|
32
|
+
l(t.target.value);
|
|
33
|
+
}, V = {
|
|
34
34
|
title: "Generate",
|
|
35
35
|
children: "Generate",
|
|
36
|
-
svgIcon:
|
|
37
|
-
},
|
|
36
|
+
svgIcon: O
|
|
37
|
+
}, w = {
|
|
38
38
|
placeholder: "Ask or generate content with AI ...",
|
|
39
39
|
rows: 2
|
|
40
|
-
}, u = Object.keys(
|
|
41
|
-
const { isFinal:
|
|
42
|
-
if (
|
|
43
|
-
const
|
|
44
|
-
const a =
|
|
40
|
+
}, u = Object.keys(c).length > 0 ? c : V, R = Object.keys(p).length > 0 ? p : w, f = (t) => {
|
|
41
|
+
const { isFinal: r, alternatives: g } = t;
|
|
42
|
+
if (r && g.length > 0) {
|
|
43
|
+
const b = g[0].transcript, k = (() => {
|
|
44
|
+
const a = s, v = a && !a.endsWith(" ") && !a.endsWith(`
|
|
45
45
|
`);
|
|
46
|
-
return a + (
|
|
46
|
+
return a + (v ? " " : "") + b;
|
|
47
47
|
})();
|
|
48
|
-
|
|
48
|
+
l(k);
|
|
49
49
|
}
|
|
50
50
|
};
|
|
51
|
-
let
|
|
52
|
-
return o && (typeof o == "object" ?
|
|
51
|
+
let m;
|
|
52
|
+
return o && (typeof o == "object" ? m = {
|
|
53
53
|
...o,
|
|
54
54
|
onResult: o.onResult || f
|
|
55
|
-
} :
|
|
55
|
+
} : m = {
|
|
56
56
|
onResult: f
|
|
57
|
-
}), /* @__PURE__ */ e.createElement(
|
|
58
|
-
|
|
57
|
+
}), /* @__PURE__ */ e.createElement(_, { name: D.name }, /* @__PURE__ */ e.createElement(B, { streaming: n.streaming, onCancel: n.onCancel }, /* @__PURE__ */ e.createElement(
|
|
58
|
+
E,
|
|
59
59
|
{
|
|
60
|
-
value:
|
|
60
|
+
value: s,
|
|
61
61
|
className: "!k-flex-col",
|
|
62
|
-
suffix: o ? /* @__PURE__ */ e.createElement(
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
fillMode: "flat",
|
|
66
|
-
...i
|
|
67
|
-
}
|
|
68
|
-
)) : void 0,
|
|
69
|
-
onChange: E,
|
|
70
|
-
...k
|
|
62
|
+
suffix: o ? /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement(z, { orientation: "horizontal" }), /* @__PURE__ */ e.createElement(F, { orientation: "horizontal" }, /* @__PURE__ */ e.createElement(j, { fillMode: "flat", ...m }))) : void 0,
|
|
63
|
+
onChange: C,
|
|
64
|
+
...R
|
|
71
65
|
}
|
|
72
|
-
),
|
|
73
|
-
|
|
66
|
+
), i && i.length > 0 && /* @__PURE__ */ e.createElement(M, { title: "Prompt Suggestions" }, /* @__PURE__ */ e.createElement(
|
|
67
|
+
$,
|
|
74
68
|
{
|
|
75
|
-
|
|
76
|
-
|
|
69
|
+
suggestionsView: n.suggestionsView,
|
|
70
|
+
suggestions: i.map((t, r) => ({
|
|
71
|
+
id: r,
|
|
77
72
|
text: t,
|
|
78
73
|
description: t
|
|
79
74
|
})),
|
|
80
|
-
onSuggestionClick: (t,
|
|
81
|
-
|
|
75
|
+
onSuggestionClick: (t, r) => {
|
|
76
|
+
T(r.text);
|
|
82
77
|
}
|
|
83
78
|
}
|
|
84
79
|
))), /* @__PURE__ */ e.createElement(y, null, /* @__PURE__ */ e.createElement(
|
|
85
|
-
|
|
80
|
+
A,
|
|
86
81
|
{
|
|
87
82
|
themeColor: "primary",
|
|
88
83
|
fillMode: "solid",
|
|
89
84
|
rounded: "full",
|
|
90
85
|
size: "medium",
|
|
91
|
-
onClick:
|
|
92
|
-
disabled: !
|
|
86
|
+
onClick: I,
|
|
87
|
+
disabled: !s.trim(),
|
|
93
88
|
...u
|
|
94
89
|
},
|
|
95
90
|
u.children
|
|
96
91
|
)));
|
|
97
92
|
};
|
|
98
93
|
export {
|
|
99
|
-
|
|
94
|
+
oe as AIPromptView
|
|
100
95
|
};
|
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("@progress/kendo-svg-icons"),e={name:"Output view",buttonText:"Output",buttonIcon:t.commentIcon},o={name:"Commands view",buttonIcon:t.moreHorizontalIcon},n={name:"
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("@progress/kendo-svg-icons"),e={name:"Output view",buttonText:"Output",buttonIcon:t.commentIcon},o={name:"Commands view",buttonIcon:t.moreHorizontalIcon},n={name:"Prompt view",buttonText:"Ask AI",buttonIcon:t.sparklesIcon};exports.commandsViewDefaults=o;exports.outputViewDefaults=e;exports.promptViewDefaults=n;
|
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react"),d=require("@progress/kendo-react-common");function u(t){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const a in t)if(a!=="default"){const o=Object.getOwnPropertyDescriptor(t,a);Object.defineProperty(r,a,o.get?o:{enumerable:!0,get:()=>t[a]})}}return r.default=t,Object.freeze(r)}const l=u(s),b=t=>{const{suggestions:r,onSuggestionClick:a,suggestionsView:o}=t,i=(e,n)=>{(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),a(e,n))},c=()=>r.map(e=>l.createElement("span",{role:"button",tabIndex:e.disabled?-1:0,"aria-label":e.description,"aria-disabled":e.disabled,onClick:n=>!e.disabled&&a(n,e),onKeyDown:n=>!e.disabled&&i(n,e),key:e.id,title:e.description,className:d.classNames(o==="classic"?"k-prompt-suggestion":"k-suggestion",{"k-disabled":e.disabled})},e.text));return o==="classic"?c():l.createElement("div",{role:"group",className:"k-suggestion-group"},c())};exports.SuggestionGroup=b;
|
|
@@ -5,13 +5,12 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
import * as
|
|
9
|
-
import { classNames as
|
|
10
|
-
const
|
|
11
|
-
const { suggestions:
|
|
8
|
+
import * as s from "react";
|
|
9
|
+
import { classNames as c } from "@progress/kendo-react-common";
|
|
10
|
+
const p = (d) => {
|
|
11
|
+
const { suggestions: o, onSuggestionClick: l, suggestionsView: r } = d, t = (e, a) => {
|
|
12
12
|
(e.key === "Enter" || e.key === " ") && (e.preventDefault(), l(e, a));
|
|
13
|
-
}
|
|
14
|
-
return /* @__PURE__ */ d.createElement("div", { role: "group", className: "k-suggestion-group" }, i.map((e) => /* @__PURE__ */ d.createElement(
|
|
13
|
+
}, i = () => o.map((e) => /* @__PURE__ */ s.createElement(
|
|
15
14
|
"span",
|
|
16
15
|
{
|
|
17
16
|
role: "button",
|
|
@@ -19,14 +18,17 @@ const n = (r) => {
|
|
|
19
18
|
"aria-label": e.description,
|
|
20
19
|
"aria-disabled": e.disabled,
|
|
21
20
|
onClick: (a) => !e.disabled && l(a, e),
|
|
22
|
-
onKeyDown: (a) => !e.disabled &&
|
|
21
|
+
onKeyDown: (a) => !e.disabled && t(a, e),
|
|
23
22
|
key: e.id,
|
|
24
23
|
title: e.description,
|
|
25
|
-
className:
|
|
24
|
+
className: c(r === "classic" ? "k-prompt-suggestion" : "k-suggestion", {
|
|
25
|
+
"k-disabled": e.disabled
|
|
26
|
+
})
|
|
26
27
|
},
|
|
27
28
|
e.text
|
|
28
|
-
))
|
|
29
|
+
));
|
|
30
|
+
return r === "classic" ? i() : /* @__PURE__ */ s.createElement("div", { role: "group", className: "k-suggestion-group" }, i());
|
|
29
31
|
};
|
|
30
32
|
export {
|
|
31
|
-
|
|
33
|
+
p as SuggestionGroup
|
|
32
34
|
};
|
|
@@ -12,4 +12,4 @@
|
|
|
12
12
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
13
13
|
*-------------------------------------------------------------------------------------------
|
|
14
14
|
*/
|
|
15
|
-
!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"),require("@progress/kendo-react-popup")):"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","@progress/kendo-react-popup"],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,e.KendoReactPopup)}(this,(function(e,t,s,n,o,a,r,i,l,c){"use strict";function p(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 m=p(t);let u=class extends m.Component{componentDidUpdate(e){!e.selected&&this.props.selected&&this.elementToFocus.focus()}};const d=class extends u{render(){return m.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?m.createElement("div",{className:"k-chat-bubble"},m.createElement("div",{className:"k-typing-indicator"},m.createElement("span",null),m.createElement("span",null),m.createElement("span",null))):this.props.template?m.createElement(this.props.template,{item:this.props.item}):this.props.item.text?m.createElement("div",{className:"k-chat-bubble"},this.props.item.text):null}getTimestampView(){let e=null;return this.props.item.timestamp&&(e=m.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=m.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")}};d.defaultProps={dateFormat:"g",tabIndex:-1};let h=d;n.registerForIntl(h);const g=(e,t)=>e&&t.author&&e.id===t.author.id,k=e=>e[e.length-1],I=e=>(t,s,n)=>{const o=n===e-1;return((e,t)=>{const s=t.timestamp,n=k(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=k(e);let o;t.typing&&!s||(n&&"message-group"===n.type&&(o=n.messages),o&&g(t.author,k(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 E=class extends u{constructor(){super(...arguments),this.onKeyDown=e=>{e.keyCode===s.Keys.enter&&this.props.onActionExecute(this.props.item,e)}}render(){return m.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 m.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;const 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 C extends v{constructor(e){super(e)}render(){const e=this.props.group.actions?this.props.group.actions.length-1:0;return m.createElement("div",{className:this.getClassNames(),onClick:this.onRequestContainerSelection,onKeyDown:this.onKeyDown},this.props.group.actions&&this.props.group.actions.map(((t,s)=>m.createElement(E,{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")}}let y=class extends u{render(){return m.createElement("div",{className:this.getClassNames(),tabIndex:this.getTabIndexValue(),onClick:this.props.onClick,ref:e=>{this.elementToFocus=e}},this.props.template?m.createElement(this.props.template,{item:this.props.item}):m.createElement("div",{className:"k-card"},m.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?m.createElement("h5",{className:"k-card-title"},this.props.item.title):null}getSubtitleView(){return this.props.item.subtitle?m.createElement("h6",{className:"k-card-subtitle"},this.props.item.subtitle):null}getContentView(){return 0===this.props.item.contentType.indexOf("image/")?m.createElement("img",{src:this.props.item.content}):this.props.item.content}};class f extends v{render(){const e=this.isCardDeckLayout(this.props),t=m.createElement("div",{className:this.getClassNames(),onKeyDown:e?void 0:this.onKeyDown},this.props.group.attachments.map(((e,t)=>m.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?m.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=m.createElement(r.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=m.createElement(r.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 b=class extends m.Component{render(){const e=this.props.item;return m.createElement("div",{className:"k-timestamp"},n.provideIntlService(this).formatDate(e.timestamp,"D"))}};n.registerForIntl(b);const x="newMessage.sendButton",w="newMessage.optionsButton",N="newMessage.messageInput",T="avatar.alt",S="messageList.ariaLabel",R="aIPrompt.noOutputs",B="aIPrompt.cancel",D={[x]:"Send",[w]:"Options",[N]:"Message",[T]:"Avatar",[S]:"Message list",[B]:"Cancel",[R]:"No output from AI available"};class L extends m.Component{render(){const{avatarUrl:e,avatarAltText:t,name:s}=this.props.group.author,o=n.provideLocalizationService(this);return m.createElement("div",{className:this.getMsgGroupClassNames()},s&&m.createElement("p",{className:"k-author"},s),e&&m.createElement(i.Avatar,{type:"image"},m.createElement("img",{src:e,alt:void 0!==t?t:o.toLanguageString(T,D[T])})),this.getGroupMessagesView())}getMsgGroupClassNames(){return s.classNames("k-message-group",{"k-no-avatar":!this.props.group.author.avatarUrl,"k-alt":g(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=[m.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(m.createElement(y,{item:t.attachments[0],template:this.props.attachmentTemplate,selected:!1,key:`att-${s}`})),n}))}}const A=m.forwardRef(((e,t)=>{const{className:n,...o}=e,a=m.useRef(null),i=m.useRef(null);m.useImperativeHandle(i,(()=>({element:a.current,props:e}))),m.useImperativeHandle(t,(()=>i.current));const l=m.useMemo((()=>s.classNames("k-chat-toolbar k-toolbar",n)),[n]);return m.useEffect((()=>{null!==a.current&&s.focusFirstFocusableChild(a.current,[...s.TABBABLE_ELEMENTS])}),[]),m.createElement(r.Toolbar,{id:e.id,ref:e=>{e&&(a.current=e.element)},className:l,...o},m.createElement("div",{className:"k-button-list k-toolbar-group"},e.children))}));A.displayName="KendoReactChatToolbar";class M extends m.Component{constructor(){super(...arguments),this.state={focused:!1},this.inputEl=null,this.toolbarBtnRef=m.createRef(),this.onInputKeyDown=e=>{switch(e.key){case"Enter":return this.sendMessage(e);case"F10":return this.openToolbar(e);default:return}},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)},this.openToolbar=e=>{null!==this.toolbarBtnRef.current&&(e.preventDefault(),this.props.onToolbarActionButtonClick(!this.props.showToolbar,e))}}render(){const e=n.provideLocalizationService(this),t=m.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(N,D[N])}),s=m.createElement(r.Button,{fillMode:"flat",themeColor:"base",className:"k-chat-send",icon:"paper-plane",svgIcon:a.paperPlaneIcon,onClick:this.sendMessage,"aria-label":e.toLanguageString(x,D[x]),dir:this.props.isDirectionRightToLeft?"rtl":void 0}),o=m.createElement(r.Button,{ref:this.toolbarBtnRef,fillMode:"flat",themeColor:"base",icon:"more-horizontal",svgIcon:a.moreHorizontalIcon,onClick:e=>this.props.onToolbarActionButtonClick(!this.props.showToolbar,e),"aria-label":e.toLanguageString(w,D[w])});return m.createElement(m.Fragment,null,m.createElement("span",{className:"k-message-box k-textbox k-input k-input-md k-rounded-md k-input-solid"},this.props.MessageBox?m.createElement(this.props.MessageBox,{messageInput:t,sendButton:s,toolbarButton:o}):m.createElement(m.Fragment,null,t,m.createElement("span",{className:"k-input-separator k-input-separator-vertical"}),m.createElement("span",{className:"k-input-suffix k-input-suffix-horizontal"},this.props.toolbar&&o,s))),this.props.showToolbar&&m.createElement(A,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",productCode:"KENDOUIREACT",productCodes:["KENDOUIREACT"],publishDate:0,version:"11.4.0-develop.8",licensingDocsUrl:"https://www.telerik.com/kendo-react-ui/components/my-license/"},P=class e extends m.Component{constructor(e){super(e),this.viewItems=[],this.isDirectionRightToLeft=!1,this.scrollToBottomOnLoadingData=!0,this.showLicenseWatermark=!1,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;const 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()}},this.showLicenseWatermark=!s.validatePackage(V,{component:"Chat"}),this.licenseMessage=s.getLicenseMessage(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 m.createElement("div",{style:{width:this.props.width,position:"relative"},onKeyDown:this.onKeyDown,className:this.getClassNames(),ref:e=>{this.chatWrapperEl=e}},m.createElement("div",{className:"k-message-list k-avatars",onBlur:this.onBlur,onFocus:this.onFocus,role:"log","aria-label":e.toLanguageString(S,D[S]),"aria-live":"polite",onScroll:e=>{this.scrollToBottomOnLoadingData=e.currentTarget.scrollTop===e.currentTarget.scrollHeight-e.currentTarget.clientHeight},ref:e=>{this.viewItemsWrapperEl=e}},m.createElement("div",{className:"k-message-list-content"},this.renderViewItems())),m.createElement(M,{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}),this.showLicenseWatermark&&m.createElement(s.WatermarkOverlay,{message:this.licenseMessage}))}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?m.createElement(b,{item:s,key:n}):"message-group"===s.type?m.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?m.createElement(f,{group:s,itemTemplate:this.props.attachmentTemplate,onRequestSelection:this.onSelectionRequested,selected:s.selectionIndex===this.state.selectedItemIndex,isLastGroup:n===t,key:n}):"action-group"===s.type?m.createElement(C,{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):[]}};P.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},P.defaultProps={messages:[],dateFormat:"g",message:h};let F=P;const K=e=>{const{suggestions:t,onSuggestionClick:n}=e;return m.createElement("div",{role:"group",className:"k-suggestion-group"},t.map((e=>m.createElement("span",{role:"button",tabIndex:e.disabled?-1:0,"aria-label":e.description,"aria-disabled":e.disabled,onClick:t=>!e.disabled&&n(t,e),onKeyDown:t=>!e.disabled&&((e,t)=>{("Enter"===e.key||" "===e.key)&&(e.preventDefault(),n(e,t))})(t,e),key:e.id,title:e.description,className:s.classNames("k-suggestion",{"k-disabled":e.disabled})},e.text))))};class O extends m.Component{constructor(){super(...arguments),this.onBtnClick=(e,t)=>{s.dispatchEvent(this.props.onActionExecute,t,this,{action:e})}}render(){return m.createElement("div",{className:"k-card"},m.createElement("img",{className:"k-card-image",src:this.props.imageUrl,style:{maxWidth:this.props.imageMaxWidth}}),m.createElement("div",{className:"k-card-body"},this.getTitleView(),this.getSubtitleView()),m.createElement("div",{className:"k-card-actions k-card-actions-vertical"},this.getActionsView()))}getActionsView(){return this.props.actions.map(((e,t)=>m.createElement("span",{className:"k-card-action",key:t},m.createElement(r.Button,{fillMode:"flat",onClick:t=>this.onBtnClick(e,t)},e.title))))}getTitleView(){let e=null;return this.props.title&&(e=m.createElement("h5",{className:"k-card-title"},this.props.title)),e}getSubtitleView(){let e=null;return this.props.subtitle&&(e=m.createElement("h6",{className:"k-card-subtitle"},this.props.subtitle)),e}}const q=e=>{const{activeView:s,toolbarItems:n,activeViewChange:o}=e;return t.createElement("div",{className:"k-prompt-header"},t.createElement(r.Toolbar,{keyboardNavigation:!1,role:"toolbar",className:"k-toolbar-flat"},n.map((e=>t.isValidElement(e)?e:t.createElement(r.Button,{key:e.name,className:s===e.name?"k-selected":"",size:"medium",themeColor:"primary",fillMode:"flat",rounded:"full",title:e.buttonText,svgIcon:e.buttonIcon,onClick:()=>(e=>{null==o||o.call(null,e)})(e.name)},e.buttonText)))))},G={name:"Output view",buttonText:"Output",buttonIcon:a.commentIcon},z={name:"Commands view",buttonIcon:a.moreHorizontalIcon},W={name:"prompt-view",buttonText:"Ask AI",buttonIcon:a.sparklesIcon},j=t.createContext([{},()=>{}]),U=()=>t.useContext(j),H=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))},$=t.forwardRef(((e,s)=>{const{children:o,streaming:i,onCancel:l}=e,c=n.useLocalization().toLanguageString(B,D[B]),[p]=U(),m=p.activeView===G.name,u=i&&m,d=t.useCallback((e=>{"Escape"===e.key&&u&&l&&(e.preventDefault(),l())}),[u,l]);return t.createElement("div",{className:"k-prompt-content",ref:s,onKeyDown:d},u&&t.createElement(r.FloatingActionButton,{onClick:l,svgIcon:a.stopSmIcon,icon:"stop-sm",size:"medium",positionMode:"absolute",className:"k-prompt-stop-fab k-generating","aria-label":c,title:c}),t.createElement("div",{className:"k-prompt-view"},o))}));$.displayName="KendoReactAIPromptContent";const _=e=>{const[t]=U();return t.activeView===e.name?e.children:null},Y=e=>{const[s,n]=t.useState(!0),{children:o,title:i}=e;return t.createElement("div",{className:"k-prompt-expander"},t.createElement(r.Button,{"aria-controls":e.id,fillMode:"flat",svgIcon:s?a.chevronUpIcon:a.chevronDownIcon,title:i,onClick:()=>n(!s),"aria-expanded":s},i),s&&t.createElement("div",{id:e.id,className:"k-prompt-expander-content"},o))},J=e=>null==e?void 0:e.map((e=>t.createElement(i.PanelBarItem,{title:e.text,key:e.id,svgIcon:e.svgIcon,data:e},e.children&&J(e.children||[])))),Q=({show:e=!1,anchor:s,onOpen:n,onClose:o,animate:a=!0,appendTo:r,popupOptions:i={},children:l,style:p})=>t.createElement(c.Popup,{show:e,anchor:s,style:p,animate:a,appendTo:r,onOpen:n,onClose:o,...i},l),X=({placeholder:e="Ask or generate content with AI...",promptValue:n,onMenuClick:o,promptInput:i=l.TextArea,generateButton:c,enableSpeechToText:p=!1,streaming:m=!1,commands:u,onPromptRequest:d,onPromptCancel:h})=>{const[g,k]=t.useState(n||""),[I,E]=s.useCustomComponent(c),[v,C]=s.useCustomComponent(i),y={svgIcon:m?a.stopSmIcon:a.paperPlaneIcon,active:(!!m).toString(),title:"Send Button","aria-label":"Send Button",disabled:!g.trim()&&!m,"aria-disabled":!g.trim()&&!m},f={placeholder:e,className:"!k-flex-row",autoSize:!0,rows:1},b=u&&u.length>0,x=Object.keys(E).length>0?E:y,w=Object.keys(C).length>0?C:f,N=e=>{const{isFinal:t,alternatives:s}=e;if(t&&s.length>0){const e=s[0].transcript,t=(()=>{const t=g,s=t&&!t.endsWith(" ")&&!t.endsWith("\n");return t+(s?" ":"")+e})();k(t)}},T=()=>{g.trim()&&d&&d(g.trim())};return t.createElement(v,{value:g,onChange:e=>{const t=e.target.value;k(t)},onKeyDown:e=>{"Enter"===e.key&&!e.shiftKey&&(e.preventDefault(),T())},prefix:b||p?t.createElement(t.Fragment,null,t.createElement(l.InputPrefix,{className:"!k-align-items-start"},b&&t.createElement(r.Button,{"aria-label":"Commands Button",title:"Commands Button",fillMode:"flat",svgIcon:a.menuIcon,onClick:o}),p&&t.createElement(r.SpeechToTextButton,{fillMode:"flat",..."object"==typeof p?{...p,onResult:p.onResult||N}:{onResult:N}})),t.createElement(l.InputSeparator,null)):void 0,suffix:t.createElement(l.InputSuffix,{className:"!k-align-items-start"},t.createElement(I,{className:s.classNames("k-prompt-send",{"k-generating":m,"k-active":m}),fillMode:"flat",onClick:m?h:T,...x})),...w})};e.AIPrompt=e=>{const n=!s.validatePackage(V,{component:"AIPrompt"}),{activeView:o,toolbarItems:a,children:r,onActiveViewChange:i,onPromptRequest:l,onCommandExecute:c,style:p,dir:m,className:u,streaming:d,loading:h,onCancel:g,...k}=e,I=a||[W,G],[E,v]=t.useState({activeView:o}),C={...E,activeView:o,streaming:d,loading:h,onCancel:g,onActiveViewChange:i,onPromptRequest:l,onCommandExecute:c};return t.createElement(j.Provider,{value:[C,e=>{v(e)}]},t.createElement("div",{className:s.classNames("k-prompt",u),style:p,dir:m,...k},t.createElement(q,{activeView:C.activeView,toolbarItems:I,activeViewChange:i}),r,n&&t.createElement(s.WatermarkOverlay,null)))},e.AIPromptCommandsView=e=>{const{commands:s}=e,[n]=U();return t.createElement(_,{name:z.name},t.createElement($,{streaming:n.streaming,onCancel:n.onCancel},t.createElement("div",{className:"k-prompt-view"},t.createElement(i.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:""},J(null!=s?s:[])))))},e.AIPromptContent=$,e.AIPromptFooter=H,e.AIPromptOutputView=e=>{const[s,o]=t.useState(""),l=t.useRef(null),[c]=U(),{outputs:p,showOutputRating:m,outputCard:u}=e,{header:d,body:h,actions:g}=u||{},k=n.useLocalization(),I=(e,t)=>{c.onPromptRequest&&c.onPromptRequest.call(null,e.prompt,{...e,ratingType:t,isRetry:!1}),E()},E=()=>{l&&l.current&&l.current.scrollTo({top:0,behavior:"smooth"})},v=t.createElement(i.Card,null,t.createElement(i.CardHeader,null,t.createElement(i.CardTitle,null,t.createElement("span",{className:"k-skeleton k-skeleton-text k-skeleton-pulse",style:{width:"200px"}})),t.createElement(i.CardSubtitle,null,t.createElement("span",{className:"k-skeleton k-skeleton-text k-skeleton-pulse",style:{width:"100%"}}))),t.createElement(i.CardBody,null,t.createElement("span",{className:"k-skeleton k-skeleton-rect k-skeleton-pulse",style:{height:"80px"}})),t.createElement(i.CardActions,null,t.createElement("span",{className:"k-skeleton k-skeleton-text k-skeleton-pulse",style:{width:"100%"}}))),C=null==p?void 0:p.map(((e,n)=>t.createElement(i.Card,{key:`${e.id}_${n}`},t.createElement(i.CardHeader,null,d?d(e):t.createElement(t.Fragment,null,e.title&&t.createElement(i.CardTitle,null,e.title),e.subTitle&&t.createElement(i.CardSubtitle,null,e.subTitle))),t.createElement(i.CardBody,null,h?h(e):e.responseContent),t.createElement(i.CardActions,null,g?g(e):t.createElement(t.Fragment,null,t.createElement(r.Button,{size:"medium",themeColor:"primary",fillMode:"flat",rounded:"medium",title:"Copy",svgIcon:s===e.id?a.checkIcon:a.copyIcon,onClick:()=>(e=>{null!=e&&e.responseContent&&navigator.clipboard.writeText(e.responseContent),o(e.id),setTimeout((()=>{o("")}),1e3)})(e)},"Copy"),t.createElement(r.Button,{size:"medium",themeColor:"base",fillMode:"flat",rounded:"medium",title:"Retry",svgIcon:a.arrowRotateCwIcon,onClick:()=>(e=>{c.onPromptRequest&&c.onPromptRequest.call(null,e.prompt,{...e,isRetry:!0}),E()})(e)},"Retry"),m&&t.createElement(t.Fragment,null,t.createElement("span",{className:"k-spacer"}),t.createElement(r.Button,{size:"medium",themeColor:"positive"===e.ratingType?"primary":"base",fillMode:"flat",rounded:"medium",title:"Rate up",svgIcon:a.thumbUpOutlineIcon,onClick:()=>I(e,"positive")}),t.createElement(r.Button,{size:"medium",themeColor:"negative"===e.ratingType?"primary":"base",fillMode:"flat",rounded:"medium",title:"Rate down",svgIcon:a.thumbDownOutlineIcon,onClick:()=>I(e,"negative")}))))))),y=t.createElement(i.Card,null,t.createElement(i.CardBody,null,k.toLanguageString(R,D[R])));return t.createElement(_,{name:G.name},t.createElement($,{ref:l,streaming:c.streaming,onCancel:c.onCancel},t.createElement("div",{className:"k-card-list"},c.loading&&v,C,(!C||0===C.length)&&!c.loading&&y)))},e.AIPromptView=e=>{const{promptInput:n=l.TextArea,generateButton:o=r.Button,enableSpeechToText:i=!1,promptValue:c,promptSuggestions:p}=e,[m,u]=t.useState(c||""),[d]=U(),[h,g]=s.useCustomComponent(o),[k,I]=s.useCustomComponent(n),E={title:"Generate",children:"Generate",svgIcon:a.sparklesIcon},v=Object.keys(g).length>0?g:E,C=Object.keys(I).length>0?I:{placeholder:"Ask or generate content with AI ...",rows:2},y=e=>{const{isFinal:t,alternatives:s}=e;if(t&&s.length>0){const e=s[0].transcript,t=(()=>{const t=m,s=t&&!t.endsWith(" ")&&!t.endsWith("\n");return t+(s?" ":"")+e})();u(t)}};let f;return i&&(f="object"==typeof i?{...i,onResult:i.onResult||y}:{onResult:y}),t.createElement(_,{name:W.name},t.createElement($,{streaming:d.streaming,onCancel:d.onCancel},t.createElement(k,{value:m,className:"!k-flex-col",suffix:i?t.createElement(l.InputSuffix,{orientation:"horizontal"},t.createElement(r.SpeechToTextButton,{fillMode:"flat",...f})):void 0,onChange:e=>{u(e.target.value)},...C}),p&&p.length>0&&t.createElement(Y,{id:"prompt-suggestions",title:"Prompt Suggestions"},t.createElement(K,{suggestions:p.map(((e,t)=>({id:t,text:e,description:e}))),onSuggestionClick:(e,t)=>{(e=>{u(e)})(t.text)}}))),t.createElement(H,null,t.createElement(h,{themeColor:"primary",fillMode:"solid",rounded:"full",size:"medium",onClick:()=>{d.onPromptRequest&&d.onPromptRequest.call(null,m),u("")},disabled:!m.trim(),...v},v.children)))},e.AIPromptViewRender=_,e.Chat=F,e.ChatMessage=h,e.HeroCard=O,e.InlineAIPrompt=e=>{const n=!s.validatePackage(V,{component:"InlineAIPrompt"}),{outputs:o=[],outputCard:c,promptInput:p=l.TextArea,generateButton:m=r.Button,promptPlaceholder:u="Ask or generate content with AI...",promptValue:d,onPromptRequest:h,onCopy:g,onDiscard:k,outputActions:I,onOutputAction:E,enableSpeechToText:v=!1,streaming:C,onPromptCancel:y,show:f=!1,anchor:b,width:x,height:w,onOpen:N,onClose:T,animate:S=!0,appendTo:R,commands:B,onCommandExecute:D,style:L,className:A,popupOptions:M={},...P}=e,[F,K]=t.useState(""),[O,q]=t.useState(!1),[G,z]=t.useState({left:0,top:0}),W=t.useRef(null),{body:j,actions:U}=c||{},H=I||[{id:"copy",text:"Copy",svgIcon:a.copyIcon,themeColor:"primary",title:"Copy"},{id:"discard",text:"Discard",svgIcon:a.cancelOutlineIcon,themeColor:"base",title:"Discard"}],_=(e,t)=>{switch(e.id){case"copy":(e=>{e.responseContent&&(navigator.clipboard.writeText(e.responseContent),K(e.id),setTimeout((()=>K("")),1e3)),null==g||g(e)})(t);break;case"discard":(e=>{null==k||k(e)})(t);break;default:null==E||E(e,t)}},Y=t.useCallback((e=>{"Escape"===e.key&&(C&&y?y():!C&&T&&T({target:null}))}),[C,y,T]),J={...L,...x&&{width:x},...w&&{height:w}},Z={...x&&{width:x},...w&&{height:w}},ee=t.createElement(t.Fragment,null,t.createElement("div",{className:s.classNames("k-prompt",A),style:J,onKeyDown:Y,...P},t.createElement($,{ref:W},o&&o.length>0&&t.createElement("div",{className:"k-card-list"},o.map(((e,s)=>t.createElement(i.Card,{key:`${e.id}_${s}`},t.createElement(i.CardBody,null,j?j(e):e.responseContent),t.createElement(i.CardActions,null,U?U(e):t.createElement(t.Fragment,null,H.map((s=>{var n;return s.spacer?t.createElement("span",{key:s.id,className:"k-spacer"}):t.createElement(r.Button,{key:s.id,size:"medium",themeColor:s.themeColor||"primary",fillMode:"flat",rounded:"medium",title:null!=(n=s.title)?n:s.text,svgIcon:"copy"===s.id&&F===e.id?a.checkIcon:s.svgIcon,onClick:()=>_(s,e)},s.text)})))))))),t.createElement(X,{promptValue:d,placeholder:u,onPromptRequest:h,onMenuClick:e=>{if(!W.current)return;const t=W.current.getBoundingClientRect();z({left:t.left,top:t.bottom}),q(!0)},onPromptCancel:y,promptInput:p,generateButton:m,enableSpeechToText:v,streaming:C,commands:B}))),n&&t.createElement(s.WatermarkOverlay,null));return t.createElement(t.Fragment,null,t.createElement(Q,{show:f,anchor:b,onOpen:N,onClose:T,animate:S,appendTo:R,popupOptions:M,style:Z},ee),t.createElement(i.ContextMenu,{show:O,offset:G,onClose:()=>{q(!1)},items:(e=>null==e?void 0:e.map((e=>({text:e.text,svgIcon:e.svgIcon,data:e,items:e.children?e.children.map((e=>({text:e.text,data:e}))):void 0}))))(B),onSelect:e=>{var t,s;const n=null==(t=e.item)?void 0:t.data;n&&(null==(s=n.children)||!s.length)&&(e=>{q(!1),D&&D(e)})(n)}}))},e.PromptHeader=q,e.SuggestionGroup=K,e.commandsViewDefaults=z,e.outputViewDefaults=G,e.promptViewDefaults=W}));
|
|
15
|
+
!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"),require("@progress/kendo-react-popup")):"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","@progress/kendo-react-popup"],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,e.KendoReactPopup)}(this,(function(e,t,s,n,o,a,r,i,l,c){"use strict";function p(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 m=p(t);let u=class extends m.Component{componentDidUpdate(e){!e.selected&&this.props.selected&&this.elementToFocus.focus()}};const d=class extends u{render(){return m.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?m.createElement("div",{className:"k-chat-bubble"},m.createElement("div",{className:"k-typing-indicator"},m.createElement("span",null),m.createElement("span",null),m.createElement("span",null))):this.props.template?m.createElement(this.props.template,{item:this.props.item}):this.props.item.text?m.createElement("div",{className:"k-chat-bubble"},this.props.item.text):null}getTimestampView(){let e=null;return this.props.item.timestamp&&(e=m.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=m.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")}};d.defaultProps={dateFormat:"g",tabIndex:-1};let h=d;n.registerForIntl(h);const g=(e,t)=>e&&t.author&&e.id===t.author.id,k=e=>e[e.length-1],I=e=>(t,s,n)=>{const o=n===e-1;return((e,t)=>{const s=t.timestamp,n=k(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=k(e);let o;t.typing&&!s||(n&&"message-group"===n.type&&(o=n.messages),o&&g(t.author,k(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 E=class extends u{constructor(){super(...arguments),this.onKeyDown=e=>{e.keyCode===s.Keys.enter&&this.props.onActionExecute(this.props.item,e)}}render(){return m.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 m.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;const 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 C extends v{constructor(e){super(e)}render(){const e=this.props.group.actions?this.props.group.actions.length-1:0;return m.createElement("div",{className:this.getClassNames(),onClick:this.onRequestContainerSelection,onKeyDown:this.onKeyDown},this.props.group.actions&&this.props.group.actions.map(((t,s)=>m.createElement(E,{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")}}let y=class extends u{render(){return m.createElement("div",{className:this.getClassNames(),tabIndex:this.getTabIndexValue(),onClick:this.props.onClick,ref:e=>{this.elementToFocus=e}},this.props.template?m.createElement(this.props.template,{item:this.props.item}):m.createElement("div",{className:"k-card"},m.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?m.createElement("h5",{className:"k-card-title"},this.props.item.title):null}getSubtitleView(){return this.props.item.subtitle?m.createElement("h6",{className:"k-card-subtitle"},this.props.item.subtitle):null}getContentView(){return 0===this.props.item.contentType.indexOf("image/")?m.createElement("img",{src:this.props.item.content}):this.props.item.content}};class f extends v{render(){const e=this.isCardDeckLayout(this.props),t=m.createElement("div",{className:this.getClassNames(),onKeyDown:e?void 0:this.onKeyDown},this.props.group.attachments.map(((e,t)=>m.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?m.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=m.createElement(r.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=m.createElement(r.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 b=class extends m.Component{render(){const e=this.props.item;return m.createElement("div",{className:"k-timestamp"},n.provideIntlService(this).formatDate(e.timestamp,"D"))}};n.registerForIntl(b);const w="newMessage.sendButton",x="newMessage.optionsButton",N="newMessage.messageInput",T="avatar.alt",S="messageList.ariaLabel",R="aIPrompt.noOutputs",B="aIPrompt.cancel",D={[w]:"Send",[x]:"Options",[N]:"Message",[T]:"Avatar",[S]:"Message list",[B]:"Cancel",[R]:"No output from AI available"};class L extends m.Component{render(){const{avatarUrl:e,avatarAltText:t,name:s}=this.props.group.author,o=n.provideLocalizationService(this);return m.createElement("div",{className:this.getMsgGroupClassNames()},s&&m.createElement("p",{className:"k-author"},s),e&&m.createElement(i.Avatar,{type:"image"},m.createElement("img",{src:e,alt:void 0!==t?t:o.toLanguageString(T,D[T])})),this.getGroupMessagesView())}getMsgGroupClassNames(){return s.classNames("k-message-group",{"k-no-avatar":!this.props.group.author.avatarUrl,"k-alt":g(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=[m.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(m.createElement(y,{item:t.attachments[0],template:this.props.attachmentTemplate,selected:!1,key:`att-${s}`})),n}))}}const M=m.forwardRef(((e,t)=>{const{className:n,...o}=e,a=m.useRef(null),i=m.useRef(null);m.useImperativeHandle(i,(()=>({element:a.current,props:e}))),m.useImperativeHandle(t,(()=>i.current));const l=m.useMemo((()=>s.classNames("k-chat-toolbar k-toolbar",n)),[n]);return m.useEffect((()=>{null!==a.current&&s.focusFirstFocusableChild(a.current,[...s.TABBABLE_ELEMENTS])}),[]),m.createElement(r.Toolbar,{id:e.id,ref:e=>{e&&(a.current=e.element)},className:l,...o},m.createElement("div",{className:"k-button-list k-toolbar-group"},e.children))}));M.displayName="KendoReactChatToolbar";class V extends m.Component{constructor(){super(...arguments),this.state={focused:!1},this.inputEl=null,this.toolbarBtnRef=m.createRef(),this.onInputKeyDown=e=>{switch(e.key){case"Enter":return this.sendMessage(e);case"F10":return this.openToolbar(e);default:return}},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)},this.openToolbar=e=>{null!==this.toolbarBtnRef.current&&(e.preventDefault(),this.props.onToolbarActionButtonClick(!this.props.showToolbar,e))}}render(){const e=n.provideLocalizationService(this),t=m.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(N,D[N])}),s=m.createElement(r.Button,{fillMode:"flat",themeColor:"base",className:"k-chat-send",icon:"paper-plane",svgIcon:a.paperPlaneIcon,onClick:this.sendMessage,"aria-label":e.toLanguageString(w,D[w]),dir:this.props.isDirectionRightToLeft?"rtl":void 0}),o=m.createElement(r.Button,{ref:this.toolbarBtnRef,fillMode:"flat",themeColor:"base",icon:"more-horizontal",svgIcon:a.moreHorizontalIcon,onClick:e=>this.props.onToolbarActionButtonClick(!this.props.showToolbar,e),"aria-label":e.toLanguageString(x,D[x])});return m.createElement(m.Fragment,null,m.createElement("span",{className:"k-message-box k-textbox k-input k-input-md k-rounded-md k-input-solid"},this.props.MessageBox?m.createElement(this.props.MessageBox,{messageInput:t,sendButton:s,toolbarButton:o}):m.createElement(m.Fragment,null,t,m.createElement("span",{className:"k-input-separator k-input-separator-vertical"}),m.createElement("span",{className:"k-input-suffix k-input-suffix-horizontal"},this.props.toolbar&&o,s))),this.props.showToolbar&&m.createElement(M,null,this.props.toolbar))}focusInput(){null!==this.inputEl&&this.inputEl.focus()}getClassNames(){return s.classNames("k-input-inner",{"k-focus":this.state.focused})}}const A=Object.freeze({name:"@progress/kendo-react-conversational-ui",productName:"KendoReact",productCode:"KENDOUIREACT",productCodes:["KENDOUIREACT"],publishDate:0,version:"11.4.0",licensingDocsUrl:"https://www.telerik.com/kendo-react-ui/components/my-license/"}),P=class e extends m.Component{constructor(e){super(e),this.viewItems=[],this.isDirectionRightToLeft=!1,this.scrollToBottomOnLoadingData=!0,this.showLicenseWatermark=!1,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;const 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()}},this.showLicenseWatermark=!s.validatePackage(A,{component:"Chat"}),this.licenseMessage=s.getLicenseMessage(A),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 m.createElement("div",{style:{width:this.props.width,position:"relative"},onKeyDown:this.onKeyDown,className:this.getClassNames(),ref:e=>{this.chatWrapperEl=e}},m.createElement("div",{className:"k-message-list k-avatars",onBlur:this.onBlur,onFocus:this.onFocus,role:"log","aria-label":e.toLanguageString(S,D[S]),"aria-live":"polite",onScroll:e=>{this.scrollToBottomOnLoadingData=e.currentTarget.scrollTop===e.currentTarget.scrollHeight-e.currentTarget.clientHeight},ref:e=>{this.viewItemsWrapperEl=e}},m.createElement("div",{className:"k-message-list-content"},this.renderViewItems())),m.createElement(V,{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}),this.showLicenseWatermark&&m.createElement(s.WatermarkOverlay,{message:this.licenseMessage}))}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?m.createElement(b,{item:s,key:n}):"message-group"===s.type?m.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?m.createElement(f,{group:s,itemTemplate:this.props.attachmentTemplate,onRequestSelection:this.onSelectionRequested,selected:s.selectionIndex===this.state.selectedItemIndex,isLastGroup:n===t,key:n}):"action-group"===s.type?m.createElement(C,{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):[]}};P.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},P.defaultProps={messages:[],dateFormat:"g",message:h};let F=P;const K=e=>{const{suggestions:t,onSuggestionClick:n,suggestionsView:o}=e,a=()=>t.map((e=>m.createElement("span",{role:"button",tabIndex:e.disabled?-1:0,"aria-label":e.description,"aria-disabled":e.disabled,onClick:t=>!e.disabled&&n(t,e),onKeyDown:t=>!e.disabled&&((e,t)=>{("Enter"===e.key||" "===e.key)&&(e.preventDefault(),n(e,t))})(t,e),key:e.id,title:e.description,className:s.classNames("classic"===o?"k-prompt-suggestion":"k-suggestion",{"k-disabled":e.disabled})},e.text)));return"classic"===o?a():m.createElement("div",{role:"group",className:"k-suggestion-group"},a())};class O extends m.Component{constructor(){super(...arguments),this.onBtnClick=(e,t)=>{s.dispatchEvent(this.props.onActionExecute,t,this,{action:e})}}render(){return m.createElement("div",{className:"k-card"},m.createElement("img",{className:"k-card-image",src:this.props.imageUrl,style:{maxWidth:this.props.imageMaxWidth}}),m.createElement("div",{className:"k-card-body"},this.getTitleView(),this.getSubtitleView()),m.createElement("div",{className:"k-card-actions k-card-actions-vertical"},this.getActionsView()))}getActionsView(){return this.props.actions.map(((e,t)=>m.createElement("span",{className:"k-card-action",key:t},m.createElement(r.Button,{fillMode:"flat",onClick:t=>this.onBtnClick(e,t)},e.title))))}getTitleView(){let e=null;return this.props.title&&(e=m.createElement("h5",{className:"k-card-title"},this.props.title)),e}getSubtitleView(){let e=null;return this.props.subtitle&&(e=m.createElement("h6",{className:"k-card-subtitle"},this.props.subtitle)),e}}const q=e=>{const{activeView:s,toolbarItems:n,activeViewChange:o}=e;return t.createElement("div",{className:"k-prompt-header"},t.createElement(r.Toolbar,{keyboardNavigation:!1,role:"toolbar",className:"k-toolbar-flat"},n.map((e=>t.isValidElement(e)?e:t.createElement(r.Button,{key:e.name,className:s===e.name?"k-selected":"",size:"medium",themeColor:"primary",fillMode:"flat",rounded:"full",title:e.buttonText,svgIcon:e.buttonIcon,onClick:()=>(e=>{null==o||o.call(null,e)})(e.name)},e.buttonText)))))},G={name:"Output view",buttonText:"Output",buttonIcon:a.commentIcon},z={name:"Commands view",buttonIcon:a.moreHorizontalIcon},W={name:"Prompt view",buttonText:"Ask AI",buttonIcon:a.sparklesIcon},j=t.createContext([{},()=>{}]),U=()=>t.useContext(j),H=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))},$=t.forwardRef(((e,s)=>{const{children:o,streaming:i,onCancel:l}=e,c=n.useLocalization().toLanguageString(B,D[B]),[p]=U(),m=p.activeView===G.name,u=i&&m,d=t.useCallback((e=>{"Escape"===e.key&&u&&l&&(e.preventDefault(),l())}),[u,l]);return t.createElement("div",{className:"k-prompt-content",ref:s,onKeyDown:d},u&&t.createElement(r.FloatingActionButton,{onClick:l,svgIcon:a.stopSmIcon,icon:"stop-sm",size:"medium",positionMode:"absolute",className:"k-prompt-stop-fab k-generating","aria-label":c,title:c}),t.createElement("div",{className:"k-prompt-view"},o))}));$.displayName="KendoReactAIPromptContent";const _=e=>{const[t]=U();return t.activeView===e.name?e.children:null},Y=e=>{const[s,n]=t.useState(!0),{children:o,title:i}=e;return t.createElement("div",{className:"k-prompt-expander"},t.createElement(r.Button,{"aria-controls":e.id,fillMode:"flat",svgIcon:s?a.chevronUpIcon:a.chevronDownIcon,title:i,onClick:()=>n(!s),"aria-expanded":s},i),s&&t.createElement("div",{id:e.id,className:"k-prompt-expander-content"},o))},J=e=>null==e?void 0:e.map((e=>t.createElement(i.PanelBarItem,{title:e.text,key:e.id,svgIcon:e.svgIcon,data:e},e.children&&J(e.children||[])))),Q=({show:e=!1,anchor:s,onOpen:n,onClose:o,animate:a=!0,appendTo:r,popupOptions:i={},children:l,style:p})=>t.createElement(c.Popup,{show:e,anchor:s,style:p,animate:a,appendTo:r,onOpen:n,onClose:o,...i},l),X=({placeholder:e="Ask or generate content with AI...",promptValue:n,onMenuClick:o,promptInput:i=l.TextArea,generateButton:c,enableSpeechToText:p=!1,streaming:m=!1,commands:u,onPromptRequest:d,onPromptCancel:h})=>{const[g,k]=t.useState(n||""),[I,E]=s.useCustomComponent(c),[v,C]=s.useCustomComponent(i),y={svgIcon:m?a.stopSmIcon:a.paperPlaneIcon,active:(!!m).toString(),title:"Send Button","aria-label":"Send Button",disabled:!g.trim()&&!m,"aria-disabled":!g.trim()&&!m},f={placeholder:e,className:"!k-flex-row",autoSize:!0,rows:1},b=u&&u.length>0,w=Object.keys(E).length>0?E:y,x=Object.keys(C).length>0?C:f,N=e=>{const{isFinal:t,alternatives:s}=e;if(t&&s.length>0){const e=s[0].transcript,t=(()=>{const t=g,s=t&&!t.endsWith(" ")&&!t.endsWith("\n");return t+(s?" ":"")+e})();k(t)}},T=()=>{g.trim()&&d&&d(g.trim())};return t.createElement(v,{value:g,onChange:e=>{const t=e.target.value;k(t)},onKeyDown:e=>{"Enter"===e.key&&!e.shiftKey&&(e.preventDefault(),T())},prefix:b||p?t.createElement(t.Fragment,null,t.createElement(l.InputPrefix,{className:"!k-align-items-start"},b&&t.createElement(r.Button,{"aria-label":"Commands Button",title:"Commands Button",fillMode:"flat",svgIcon:a.menuIcon,onClick:o}),p&&t.createElement(r.SpeechToTextButton,{fillMode:"flat",..."object"==typeof p?{...p,onResult:p.onResult||N}:{onResult:N}})),t.createElement(l.InputSeparator,null)):void 0,suffix:t.createElement(l.InputSuffix,{className:"!k-align-items-start"},t.createElement(I,{className:s.classNames("k-prompt-send",{"k-generating":m,"k-active":m}),fillMode:"flat",onClick:m?h:T,...w})),...x})};e.AIPrompt=e=>{const n=!s.validatePackage(A,{component:"AIPrompt"}),o=s.getLicenseMessage(A),{activeView:a,toolbarItems:r,children:i,onActiveViewChange:l,onPromptRequest:c,onCommandExecute:p,style:m,dir:u,className:d,streaming:h,loading:g,onCancel:k,suggestionsView:I,...E}=e,v=r||[W,G],[C,y]=t.useState({activeView:a}),f={...C,activeView:a,streaming:h,loading:g,suggestionsView:null!=I?I:"classic",onCancel:k,onActiveViewChange:l,onPromptRequest:c,onCommandExecute:p};return t.createElement(j.Provider,{value:[f,e=>{y(e)}]},t.createElement("div",{className:s.classNames("k-prompt",d),style:m,dir:u,...E},t.createElement(q,{activeView:f.activeView,toolbarItems:v,activeViewChange:l}),i,n&&t.createElement(s.WatermarkOverlay,{message:o})))},e.AIPromptCommandsView=e=>{const{commands:s}=e,[n]=U();return t.createElement(_,{name:z.name},t.createElement($,{streaming:n.streaming,onCancel:n.onCancel},t.createElement("div",{className:"k-prompt-view"},t.createElement(i.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:""},J(null!=s?s:[])))))},e.AIPromptContent=$,e.AIPromptFooter=H,e.AIPromptOutputView=e=>{const[s,o]=t.useState(""),l=t.useRef(null),[c]=U(),{outputs:p,showOutputRating:m,outputCard:u}=e,{header:d,body:h,actions:g}=u||{},k=n.useLocalization(),I=(e,t)=>{c.onPromptRequest&&c.onPromptRequest.call(null,e.prompt,{...e,ratingType:t,isRetry:!1}),E()},E=()=>{l&&l.current&&l.current.scrollTo({top:0,behavior:"smooth"})},v=t.createElement(i.Card,null,t.createElement(i.CardHeader,null,t.createElement(i.CardTitle,null,t.createElement("span",{className:"k-skeleton k-skeleton-text k-skeleton-pulse",style:{width:"200px"}})),t.createElement(i.CardSubtitle,null,t.createElement("span",{className:"k-skeleton k-skeleton-text k-skeleton-pulse",style:{width:"100%"}}))),t.createElement(i.CardBody,null,t.createElement("span",{className:"k-skeleton k-skeleton-rect k-skeleton-pulse",style:{height:"80px"}})),t.createElement(i.CardActions,null,t.createElement("span",{className:"k-skeleton k-skeleton-text k-skeleton-pulse",style:{width:"100%"}}))),C=null==p?void 0:p.map(((e,n)=>t.createElement(i.Card,{key:`${e.id}_${n}`},t.createElement(i.CardHeader,null,d?d(e):t.createElement(t.Fragment,null,e.title&&t.createElement(i.CardTitle,null,e.title),e.subTitle&&t.createElement(i.CardSubtitle,null,e.subTitle))),t.createElement(i.CardBody,null,h?h(e):e.responseContent),t.createElement(i.CardActions,null,g?g(e):t.createElement(t.Fragment,null,t.createElement(r.Button,{size:"medium",themeColor:"primary",fillMode:"flat",rounded:"medium",title:"Copy",svgIcon:s===e.id?a.checkIcon:a.copyIcon,onClick:()=>(e=>{null!=e&&e.responseContent&&navigator.clipboard.writeText(e.responseContent),o(e.id),setTimeout((()=>{o("")}),1e3)})(e)},"Copy"),t.createElement(r.Button,{size:"medium",themeColor:"base",fillMode:"flat",rounded:"medium",title:"Retry",svgIcon:a.arrowRotateCwIcon,onClick:()=>(e=>{c.onPromptRequest&&c.onPromptRequest.call(null,e.prompt,{...e,isRetry:!0}),E()})(e)},"Retry"),m&&t.createElement(t.Fragment,null,t.createElement("span",{className:"k-spacer"}),t.createElement(r.Button,{size:"medium",themeColor:"positive"===e.ratingType?"primary":"base",fillMode:"flat",rounded:"medium",title:"Rate up",svgIcon:a.thumbUpOutlineIcon,onClick:()=>I(e,"positive")}),t.createElement(r.Button,{size:"medium",themeColor:"negative"===e.ratingType?"primary":"base",fillMode:"flat",rounded:"medium",title:"Rate down",svgIcon:a.thumbDownOutlineIcon,onClick:()=>I(e,"negative")}))))))),y=t.createElement(i.Card,null,t.createElement(i.CardBody,null,k.toLanguageString(R,D[R])));return t.createElement(_,{name:G.name},t.createElement($,{ref:l,streaming:c.streaming,onCancel:c.onCancel},t.createElement("div",{className:"k-card-list"},c.loading&&v,C,(!C||0===C.length)&&!c.loading&&y)))},e.AIPromptView=e=>{const{promptInput:n=l.TextArea,generateButton:o=r.Button,enableSpeechToText:i=!1,promptValue:c,promptSuggestions:p}=e,[m,u]=t.useState(c||""),[d]=U(),[h,g]=s.useCustomComponent(o),[k,I]=s.useCustomComponent(n),E={title:"Generate",children:"Generate",svgIcon:a.sparklesIcon},v=Object.keys(g).length>0?g:E,C=Object.keys(I).length>0?I:{placeholder:"Ask or generate content with AI ...",rows:2},y=e=>{const{isFinal:t,alternatives:s}=e;if(t&&s.length>0){const e=s[0].transcript,t=(()=>{const t=m,s=t&&!t.endsWith(" ")&&!t.endsWith("\n");return t+(s?" ":"")+e})();u(t)}};let f;return i&&(f="object"==typeof i?{...i,onResult:i.onResult||y}:{onResult:y}),t.createElement(_,{name:W.name},t.createElement($,{streaming:d.streaming,onCancel:d.onCancel},t.createElement(k,{value:m,className:"!k-flex-col",suffix:i?t.createElement(t.Fragment,null,t.createElement(l.InputSeparator,{orientation:"horizontal"}),t.createElement(l.InputSuffix,{orientation:"horizontal"},t.createElement(r.SpeechToTextButton,{fillMode:"flat",...f}))):void 0,onChange:e=>{u(e.target.value)},...C}),p&&p.length>0&&t.createElement(Y,{title:"Prompt Suggestions"},t.createElement(K,{suggestionsView:d.suggestionsView,suggestions:p.map(((e,t)=>({id:t,text:e,description:e}))),onSuggestionClick:(e,t)=>{(e=>{u(e)})(t.text)}}))),t.createElement(H,null,t.createElement(h,{themeColor:"primary",fillMode:"solid",rounded:"full",size:"medium",onClick:()=>{d.onPromptRequest&&d.onPromptRequest.call(null,m),u("")},disabled:!m.trim(),...v},v.children)))},e.AIPromptViewRender=_,e.Chat=F,e.ChatMessage=h,e.HeroCard=O,e.InlineAIPrompt=e=>{const n=!s.validatePackage(A,{component:"InlineAIPrompt"}),o=s.getLicenseMessage(A),{outputs:c=[],outputCard:p,promptInput:m=l.TextArea,generateButton:u=r.Button,promptPlaceholder:d="Ask or generate content with AI...",promptValue:h,onPromptRequest:g,onCopy:k,onDiscard:I,outputActions:E,onOutputAction:v,enableSpeechToText:C=!1,streaming:y,onPromptCancel:f,show:b=!1,anchor:w,width:x,height:N,onOpen:T,onClose:S,animate:R=!0,appendTo:B,commands:D,onCommandExecute:L,style:M,className:V,popupOptions:P={},...F}=e,[K,O]=t.useState(""),[q,G]=t.useState(!1),[z,W]=t.useState({left:0,top:0}),j=t.useRef(null),{body:U,actions:H}=p||{},_=E||[{id:"copy",text:"Copy",svgIcon:a.copyIcon,themeColor:"primary",title:"Copy"},{id:"discard",text:"Discard",svgIcon:a.cancelOutlineIcon,themeColor:"base",title:"Discard"}],Y=(e,t)=>{switch(e.id){case"copy":(e=>{e.responseContent&&(navigator.clipboard.writeText(e.responseContent),O(e.id),setTimeout((()=>O("")),1e3)),null==k||k(e)})(t);break;case"discard":(e=>{null==I||I(e)})(t);break;default:null==v||v(e,t)}},J=t.useCallback((e=>{"Escape"===e.key&&(y&&f?f():!y&&S&&S({target:null}))}),[y,f,S]),Z={...M,...x&&{width:x},...N&&{height:N}},ee={...x&&{width:x},...N&&{height:N}},te=t.createElement(t.Fragment,null,t.createElement("div",{className:s.classNames("k-prompt",V),style:Z,onKeyDown:J,...F},t.createElement($,{ref:j},c&&c.length>0&&t.createElement("div",{className:"k-card-list"},c.map(((e,s)=>t.createElement(i.Card,{key:`${e.id}_${s}`},t.createElement(i.CardBody,null,U?U(e):e.responseContent),t.createElement(i.CardActions,null,H?H(e):t.createElement(t.Fragment,null,_.map((s=>{var n;return s.spacer?t.createElement("span",{key:s.id,className:"k-spacer"}):t.createElement(r.Button,{key:s.id,size:"medium",themeColor:s.themeColor||"primary",fillMode:"flat",rounded:"medium",title:null!=(n=s.title)?n:s.text,svgIcon:"copy"===s.id&&K===e.id?a.checkIcon:s.svgIcon,onClick:()=>Y(s,e)},s.text)})))))))),t.createElement(X,{promptValue:h,placeholder:d,onPromptRequest:g,onMenuClick:e=>{if(!j.current)return;const t=j.current.getBoundingClientRect();W({left:t.left,top:t.bottom}),G(!0)},onPromptCancel:f,promptInput:m,generateButton:u,enableSpeechToText:C,streaming:y,commands:D}))),n&&t.createElement(s.WatermarkOverlay,{message:o}));return t.createElement(t.Fragment,null,t.createElement(Q,{show:b,anchor:w,onOpen:T,onClose:S,animate:R,appendTo:B,popupOptions:P,style:ee},te),t.createElement(i.ContextMenu,{show:q,offset:z,onClose:()=>{G(!1)},items:(e=>null==e?void 0:e.map((e=>({text:e.text,svgIcon:e.svgIcon,data:e,items:e.children?e.children.map((e=>({text:e.text,data:e}))):void 0}))))(D),onSelect:e=>{var t,s;const n=null==(t=e.item)?void 0:t.data;n&&(null==(s=n.children)||!s.length)&&(e=>{G(!1),L&&L(e)})(n)}}))},e.PromptHeader=q,e.SuggestionGroup=K,e.commandsViewDefaults=z,e.outputViewDefaults=G,e.promptViewDefaults=W}));
|
package/index.d.mts
CHANGED
|
@@ -346,6 +346,10 @@ export declare interface AIPromptProps extends default_3.HTMLAttributes<HTMLElem
|
|
|
346
346
|
* ```
|
|
347
347
|
*/
|
|
348
348
|
loading?: boolean;
|
|
349
|
+
/**
|
|
350
|
+
* Optionally specifies the rendering for the suggestions displayed in the AI Prompt component.
|
|
351
|
+
*/
|
|
352
|
+
suggestionsView?: SuggestionsView;
|
|
349
353
|
}
|
|
350
354
|
|
|
351
355
|
/**
|
|
@@ -713,6 +717,7 @@ export declare interface ChatSuggestion {
|
|
|
713
717
|
text: string;
|
|
714
718
|
description?: string;
|
|
715
719
|
disabled?: boolean;
|
|
720
|
+
suggestionsView?: SuggestionsView;
|
|
716
721
|
}
|
|
717
722
|
|
|
718
723
|
/**
|
|
@@ -1117,8 +1122,17 @@ export declare const SuggestionGroup: React_2.FC<SuggestionGroupProps>;
|
|
|
1117
1122
|
declare interface SuggestionGroupProps {
|
|
1118
1123
|
suggestions: ChatSuggestion[];
|
|
1119
1124
|
onSuggestionClick: (event: React_2.MouseEvent<HTMLSpanElement>, suggestion: ChatSuggestion) => void;
|
|
1125
|
+
suggestionsView?: SuggestionsView;
|
|
1120
1126
|
}
|
|
1121
1127
|
|
|
1128
|
+
/**
|
|
1129
|
+
* Represents the rendering options for suggestions in the AI Prompt component.
|
|
1130
|
+
* 'suggestionsView' can be either 'classic' or 'modern'.
|
|
1131
|
+
* - 'classic': Uses a rectangular styling for suggestions.
|
|
1132
|
+
* - 'modern': Uses a chip-like styling for suggestions.
|
|
1133
|
+
*/
|
|
1134
|
+
export declare type SuggestionsView = 'classic' | 'modern';
|
|
1135
|
+
|
|
1122
1136
|
/**
|
|
1123
1137
|
* Represents a participant in a Chat conversation.
|
|
1124
1138
|
*/
|
package/index.d.ts
CHANGED
|
@@ -346,6 +346,10 @@ export declare interface AIPromptProps extends default_3.HTMLAttributes<HTMLElem
|
|
|
346
346
|
* ```
|
|
347
347
|
*/
|
|
348
348
|
loading?: boolean;
|
|
349
|
+
/**
|
|
350
|
+
* Optionally specifies the rendering for the suggestions displayed in the AI Prompt component.
|
|
351
|
+
*/
|
|
352
|
+
suggestionsView?: SuggestionsView;
|
|
349
353
|
}
|
|
350
354
|
|
|
351
355
|
/**
|
|
@@ -713,6 +717,7 @@ export declare interface ChatSuggestion {
|
|
|
713
717
|
text: string;
|
|
714
718
|
description?: string;
|
|
715
719
|
disabled?: boolean;
|
|
720
|
+
suggestionsView?: SuggestionsView;
|
|
716
721
|
}
|
|
717
722
|
|
|
718
723
|
/**
|
|
@@ -1117,8 +1122,17 @@ export declare const SuggestionGroup: React_2.FC<SuggestionGroupProps>;
|
|
|
1117
1122
|
declare interface SuggestionGroupProps {
|
|
1118
1123
|
suggestions: ChatSuggestion[];
|
|
1119
1124
|
onSuggestionClick: (event: React_2.MouseEvent<HTMLSpanElement>, suggestion: ChatSuggestion) => void;
|
|
1125
|
+
suggestionsView?: SuggestionsView;
|
|
1120
1126
|
}
|
|
1121
1127
|
|
|
1128
|
+
/**
|
|
1129
|
+
* Represents the rendering options for suggestions in the AI Prompt component.
|
|
1130
|
+
* 'suggestionsView' can be either 'classic' or 'modern'.
|
|
1131
|
+
* - 'classic': Uses a rectangular styling for suggestions.
|
|
1132
|
+
* - 'modern': Uses a chip-like styling for suggestions.
|
|
1133
|
+
*/
|
|
1134
|
+
export declare type SuggestionsView = 'classic' | 'modern';
|
|
1135
|
+
|
|
1122
1136
|
/**
|
|
1123
1137
|
* Represents a participant in a Chat conversation.
|
|
1124
1138
|
*/
|
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react"),m=require("@progress/kendo-react-layout"),
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react"),m=require("@progress/kendo-react-layout"),P=require("@progress/kendo-react-buttons"),ie=require("@progress/kendo-react-inputs"),g=require("@progress/kendo-svg-icons"),d=require("@progress/kendo-react-common"),x=require("../package-metadata.js"),me=require("./InlineAIPromptPopup.js"),de=require("./InlineAIPromptInput.js"),pe=require("../ai-prompt/AIPromptContent.js"),ue=b=>{const S=!d.validatePackage(x.packageMetadata,{component:"InlineAIPrompt"}),q=d.getLicenseMessage(x.packageMetadata),{outputs:p=[],outputCard:w,promptInput:O=ie.TextArea,generateButton:R=P.Button,promptPlaceholder:A="Ask or generate content with AI...",promptValue:T,onPromptRequest:B,onCopy:u,onDiscard:C,outputActions:D,onOutputAction:I,enableSpeechToText:N=!1,streaming:s,onPromptCancel:r,show:F=!1,anchor:K,width:c,height:l,onOpen:W,onClose:i,animate:$=!0,appendTo:j,commands:k,onCommandExecute:y,style:z,className:V,popupOptions:_={},...G}=b,[H,E]=t.useState(""),[J,h]=t.useState(!1),[Q,U]=t.useState({left:0,top:0}),f=t.useRef(null),{body:M,actions:v}=w||{},X=[{id:"copy",text:"Copy",svgIcon:g.copyIcon,themeColor:"primary",title:"Copy"},{id:"discard",text:"Discard",svgIcon:g.cancelOutlineIcon,themeColor:"base",title:"Discard"}],Y=D||X,Z=e=>{e.responseContent&&(navigator.clipboard.writeText(e.responseContent),E(e.id),setTimeout(()=>E(""),1e3)),u==null||u(e)},L=e=>{C==null||C(e)},ee=(e,n)=>{switch(e.id){case"copy":Z(n);break;case"discard":L(n);break;default:I==null||I(e,n);break}},te=e=>{if(!f.current)return;const n=f.current.getBoundingClientRect();U({left:n.left,top:n.bottom}),h(!0)},ne=()=>{h(!1)},ae=e=>{h(!1),y&&y(e)},oe=e=>e==null?void 0:e.map(n=>({text:n.text,svgIcon:n.svgIcon,data:n,items:n.children?n.children.map(a=>({text:a.text,data:a})):void 0})),se=t.useCallback(e=>{e.key==="Escape"&&(s&&r?r():!s&&i&&i({target:null}))},[s,r,i]),re={...z,...c&&{width:c},...l&&{height:l}},ce={...c&&{width:c},...l&&{height:l}},le=t.createElement(t.Fragment,null,t.createElement("div",{className:d.classNames("k-prompt",V),style:re,onKeyDown:se,...G},t.createElement(pe.AIPromptContent,{ref:f},p&&p.length>0&&t.createElement("div",{className:"k-card-list"},p.map((e,n)=>t.createElement(m.Card,{key:`${e.id}_${n}`},t.createElement(m.CardBody,null,M?M(e):e.responseContent),t.createElement(m.CardActions,null,v?v(e):t.createElement(t.Fragment,null,Y.map(a=>{var o;return a.spacer?t.createElement("span",{key:a.id,className:"k-spacer"}):t.createElement(P.Button,{key:a.id,size:"medium",themeColor:a.themeColor||"primary",fillMode:"flat",rounded:"medium",title:(o=a.title)!=null?o:a.text,svgIcon:a.id==="copy"&&H===e.id?g.checkIcon:a.svgIcon,onClick:()=>ee(a,e)},a.text)})))))),t.createElement(de.InlineAIPromptInput,{promptValue:T,placeholder:A,onPromptRequest:B,onMenuClick:te,onPromptCancel:r,promptInput:O,generateButton:R,enableSpeechToText:N,streaming:s,commands:k}))),S&&t.createElement(d.WatermarkOverlay,{message:q}));return t.createElement(t.Fragment,null,t.createElement(me.InlineAIPromptPopup,{show:F,anchor:K,onOpen:W,onClose:i,animate:$,appendTo:j,popupOptions:_,style:ce},le),t.createElement(m.ContextMenu,{show:J,offset:Q,onClose:ne,items:oe(k),onSelect:e=>{var a,o;const n=(a=e.item)==null?void 0:a.data;n&&!((o=n.children)!=null&&o.length)&&ae(n)}}))};exports.InlineAIPrompt=ue;
|
|
@@ -6,181 +6,181 @@
|
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
8
|
import t from "react";
|
|
9
|
-
import { Card as
|
|
9
|
+
import { Card as re, CardBody as se, CardActions as le, ContextMenu as ce } from "@progress/kendo-react-layout";
|
|
10
10
|
import { Button as E } from "@progress/kendo-react-buttons";
|
|
11
|
-
import { TextArea as
|
|
12
|
-
import { checkIcon as
|
|
13
|
-
import { validatePackage as
|
|
14
|
-
import { packageMetadata as
|
|
15
|
-
import { InlineAIPromptPopup as
|
|
16
|
-
import { InlineAIPromptInput as
|
|
17
|
-
import { AIPromptContent as
|
|
18
|
-
const
|
|
19
|
-
const
|
|
11
|
+
import { TextArea as me } from "@progress/kendo-react-inputs";
|
|
12
|
+
import { checkIcon as ie, copyIcon as de, cancelOutlineIcon as pe } from "@progress/kendo-svg-icons";
|
|
13
|
+
import { validatePackage as fe, getLicenseMessage as Ce, classNames as he, WatermarkOverlay as ue } from "@progress/kendo-react-common";
|
|
14
|
+
import { packageMetadata as x } from "../package-metadata.mjs";
|
|
15
|
+
import { InlineAIPromptPopup as ge } from "./InlineAIPromptPopup.mjs";
|
|
16
|
+
import { InlineAIPromptInput as ke } from "./InlineAIPromptInput.mjs";
|
|
17
|
+
import { AIPromptContent as ye } from "../ai-prompt/AIPromptContent.mjs";
|
|
18
|
+
const Ae = (v) => {
|
|
19
|
+
const M = !fe(x, { component: "InlineAIPrompt" }), b = Ce(x), {
|
|
20
20
|
outputs: i = [],
|
|
21
|
-
outputCard:
|
|
22
|
-
promptInput:
|
|
23
|
-
generateButton:
|
|
24
|
-
promptPlaceholder:
|
|
25
|
-
promptValue:
|
|
26
|
-
onPromptRequest:
|
|
21
|
+
outputCard: w,
|
|
22
|
+
promptInput: O = me,
|
|
23
|
+
generateButton: P = E,
|
|
24
|
+
promptPlaceholder: S = "Ask or generate content with AI...",
|
|
25
|
+
promptValue: T,
|
|
26
|
+
onPromptRequest: A,
|
|
27
27
|
onCopy: d,
|
|
28
28
|
onDiscard: p,
|
|
29
|
-
outputActions:
|
|
29
|
+
outputActions: B,
|
|
30
30
|
onOutputAction: f,
|
|
31
|
-
enableSpeechToText:
|
|
31
|
+
enableSpeechToText: D = !1,
|
|
32
32
|
streaming: r,
|
|
33
|
-
onPromptCancel:
|
|
34
|
-
show:
|
|
35
|
-
anchor:
|
|
36
|
-
width:
|
|
33
|
+
onPromptCancel: s,
|
|
34
|
+
show: N = !1,
|
|
35
|
+
anchor: R,
|
|
36
|
+
width: l,
|
|
37
37
|
height: c,
|
|
38
|
-
onOpen:
|
|
38
|
+
onOpen: F,
|
|
39
39
|
onClose: m,
|
|
40
|
-
animate:
|
|
41
|
-
appendTo:
|
|
40
|
+
animate: _ = !0,
|
|
41
|
+
appendTo: K,
|
|
42
42
|
commands: u,
|
|
43
|
-
onCommandExecute:
|
|
44
|
-
style:
|
|
45
|
-
className:
|
|
46
|
-
popupOptions:
|
|
47
|
-
|
|
48
|
-
} =
|
|
43
|
+
onCommandExecute: g,
|
|
44
|
+
style: W,
|
|
45
|
+
className: $,
|
|
46
|
+
popupOptions: q = {},
|
|
47
|
+
...z
|
|
48
|
+
} = v, [V, k] = t.useState(""), [j, C] = t.useState(!1), [G, H] = t.useState({
|
|
49
49
|
left: 0,
|
|
50
50
|
top: 0
|
|
51
|
-
}), h = t.useRef(null), { body:
|
|
51
|
+
}), h = t.useRef(null), { body: y, actions: I } = w || {}, J = B || [
|
|
52
52
|
{
|
|
53
53
|
id: "copy",
|
|
54
54
|
text: "Copy",
|
|
55
|
-
svgIcon:
|
|
55
|
+
svgIcon: de,
|
|
56
56
|
themeColor: "primary",
|
|
57
57
|
title: "Copy"
|
|
58
58
|
},
|
|
59
59
|
{
|
|
60
60
|
id: "discard",
|
|
61
61
|
text: "Discard",
|
|
62
|
-
svgIcon:
|
|
62
|
+
svgIcon: pe,
|
|
63
63
|
themeColor: "base",
|
|
64
64
|
title: "Discard"
|
|
65
65
|
}
|
|
66
|
-
],
|
|
67
|
-
e.responseContent && (navigator.clipboard.writeText(e.responseContent),
|
|
68
|
-
},
|
|
66
|
+
], Q = (e) => {
|
|
67
|
+
e.responseContent && (navigator.clipboard.writeText(e.responseContent), k(e.id), setTimeout(() => k(""), 1e3)), d == null || d(e);
|
|
68
|
+
}, U = (e) => {
|
|
69
69
|
p == null || p(e);
|
|
70
|
-
},
|
|
70
|
+
}, X = (e, n) => {
|
|
71
71
|
switch (e.id) {
|
|
72
72
|
case "copy":
|
|
73
|
-
|
|
73
|
+
Q(n);
|
|
74
74
|
break;
|
|
75
75
|
case "discard":
|
|
76
|
-
|
|
76
|
+
U(n);
|
|
77
77
|
break;
|
|
78
78
|
default:
|
|
79
79
|
f == null || f(e, n);
|
|
80
80
|
break;
|
|
81
81
|
}
|
|
82
|
-
},
|
|
82
|
+
}, Y = (e) => {
|
|
83
83
|
if (!h.current)
|
|
84
84
|
return;
|
|
85
85
|
const n = h.current.getBoundingClientRect();
|
|
86
|
-
|
|
86
|
+
H({
|
|
87
87
|
left: n.left,
|
|
88
88
|
top: n.bottom
|
|
89
89
|
}), C(!0);
|
|
90
|
-
},
|
|
90
|
+
}, Z = () => {
|
|
91
91
|
C(!1);
|
|
92
|
-
},
|
|
93
|
-
C(!1),
|
|
94
|
-
},
|
|
92
|
+
}, L = (e) => {
|
|
93
|
+
C(!1), g && g(e);
|
|
94
|
+
}, ee = (e) => e == null ? void 0 : e.map((n) => ({
|
|
95
95
|
text: n.text,
|
|
96
96
|
svgIcon: n.svgIcon,
|
|
97
97
|
data: n,
|
|
98
|
-
items: n.children ? n.children.map((
|
|
99
|
-
text:
|
|
100
|
-
data:
|
|
98
|
+
items: n.children ? n.children.map((a) => ({
|
|
99
|
+
text: a.text,
|
|
100
|
+
data: a
|
|
101
101
|
})) : void 0
|
|
102
|
-
})),
|
|
102
|
+
})), te = t.useCallback(
|
|
103
103
|
(e) => {
|
|
104
|
-
e.key === "Escape" && (r &&
|
|
104
|
+
e.key === "Escape" && (r && s ? s() : !r && m && m({ target: null }));
|
|
105
105
|
},
|
|
106
|
-
[r,
|
|
107
|
-
),
|
|
108
|
-
...
|
|
109
|
-
...
|
|
106
|
+
[r, s, m]
|
|
107
|
+
), ne = {
|
|
108
|
+
...W,
|
|
109
|
+
...l && { width: l },
|
|
110
110
|
...c && { height: c }
|
|
111
|
-
},
|
|
112
|
-
...
|
|
111
|
+
}, ae = {
|
|
112
|
+
...l && { width: l },
|
|
113
113
|
...c && { height: c }
|
|
114
|
-
},
|
|
114
|
+
}, oe = /* @__PURE__ */ t.createElement(t.Fragment, null, /* @__PURE__ */ t.createElement(
|
|
115
115
|
"div",
|
|
116
116
|
{
|
|
117
|
-
className:
|
|
118
|
-
style:
|
|
119
|
-
onKeyDown:
|
|
120
|
-
|
|
117
|
+
className: he("k-prompt", $),
|
|
118
|
+
style: ne,
|
|
119
|
+
onKeyDown: te,
|
|
120
|
+
...z
|
|
121
121
|
},
|
|
122
|
-
/* @__PURE__ */ t.createElement(
|
|
123
|
-
(
|
|
124
|
-
var
|
|
125
|
-
return
|
|
122
|
+
/* @__PURE__ */ t.createElement(ye, { ref: h }, i && i.length > 0 && /* @__PURE__ */ t.createElement("div", { className: "k-card-list" }, i.map((e, n) => /* @__PURE__ */ t.createElement(re, { key: `${e.id}_${n}` }, /* @__PURE__ */ t.createElement(se, null, y ? y(e) : e.responseContent), /* @__PURE__ */ t.createElement(le, null, I ? I(e) : /* @__PURE__ */ t.createElement(t.Fragment, null, J.map(
|
|
123
|
+
(a) => {
|
|
124
|
+
var o;
|
|
125
|
+
return a.spacer ? /* @__PURE__ */ t.createElement("span", { key: a.id, className: "k-spacer" }) : /* @__PURE__ */ t.createElement(
|
|
126
126
|
E,
|
|
127
127
|
{
|
|
128
|
-
key:
|
|
128
|
+
key: a.id,
|
|
129
129
|
size: "medium",
|
|
130
|
-
themeColor:
|
|
130
|
+
themeColor: a.themeColor || "primary",
|
|
131
131
|
fillMode: "flat",
|
|
132
132
|
rounded: "medium",
|
|
133
|
-
title: (
|
|
134
|
-
svgIcon:
|
|
135
|
-
onClick: () =>
|
|
133
|
+
title: (o = a.title) != null ? o : a.text,
|
|
134
|
+
svgIcon: a.id === "copy" && V === e.id ? ie : a.svgIcon,
|
|
135
|
+
onClick: () => X(a, e)
|
|
136
136
|
},
|
|
137
|
-
|
|
137
|
+
a.text
|
|
138
138
|
);
|
|
139
139
|
}
|
|
140
140
|
)))))), /* @__PURE__ */ t.createElement(
|
|
141
|
-
|
|
141
|
+
ke,
|
|
142
142
|
{
|
|
143
|
-
promptValue:
|
|
144
|
-
placeholder:
|
|
145
|
-
onPromptRequest:
|
|
146
|
-
onMenuClick:
|
|
147
|
-
onPromptCancel:
|
|
148
|
-
promptInput:
|
|
149
|
-
generateButton:
|
|
150
|
-
enableSpeechToText:
|
|
143
|
+
promptValue: T,
|
|
144
|
+
placeholder: S,
|
|
145
|
+
onPromptRequest: A,
|
|
146
|
+
onMenuClick: Y,
|
|
147
|
+
onPromptCancel: s,
|
|
148
|
+
promptInput: O,
|
|
149
|
+
generateButton: P,
|
|
150
|
+
enableSpeechToText: D,
|
|
151
151
|
streaming: r,
|
|
152
152
|
commands: u
|
|
153
153
|
}
|
|
154
154
|
))
|
|
155
|
-
),
|
|
155
|
+
), M && /* @__PURE__ */ t.createElement(ue, { message: b }));
|
|
156
156
|
return /* @__PURE__ */ t.createElement(t.Fragment, null, /* @__PURE__ */ t.createElement(
|
|
157
|
-
|
|
157
|
+
ge,
|
|
158
158
|
{
|
|
159
|
-
show:
|
|
160
|
-
anchor:
|
|
161
|
-
onOpen:
|
|
159
|
+
show: N,
|
|
160
|
+
anchor: R,
|
|
161
|
+
onOpen: F,
|
|
162
162
|
onClose: m,
|
|
163
|
-
animate:
|
|
164
|
-
appendTo:
|
|
165
|
-
popupOptions:
|
|
166
|
-
style:
|
|
163
|
+
animate: _,
|
|
164
|
+
appendTo: K,
|
|
165
|
+
popupOptions: q,
|
|
166
|
+
style: ae
|
|
167
167
|
},
|
|
168
|
-
|
|
168
|
+
oe
|
|
169
169
|
), /* @__PURE__ */ t.createElement(
|
|
170
|
-
|
|
170
|
+
ce,
|
|
171
171
|
{
|
|
172
|
-
show:
|
|
173
|
-
offset:
|
|
174
|
-
onClose:
|
|
175
|
-
items:
|
|
172
|
+
show: j,
|
|
173
|
+
offset: G,
|
|
174
|
+
onClose: Z,
|
|
175
|
+
items: ee(u),
|
|
176
176
|
onSelect: (e) => {
|
|
177
|
-
var
|
|
178
|
-
const n = (
|
|
179
|
-
n && !((
|
|
177
|
+
var a, o;
|
|
178
|
+
const n = (a = e.item) == null ? void 0 : a.data;
|
|
179
|
+
n && !((o = n.children) != null && o.length) && L(n);
|
|
180
180
|
}
|
|
181
181
|
}
|
|
182
182
|
));
|
|
183
183
|
};
|
|
184
184
|
export {
|
|
185
|
-
|
|
185
|
+
Ae as InlineAIPrompt
|
|
186
186
|
};
|
package/package-metadata.js
CHANGED
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e={name:"@progress/kendo-react-conversational-ui",productName:"KendoReact",productCode:"KENDOUIREACT",productCodes:["KENDOUIREACT"],publishDate:
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=Object.freeze({name:"@progress/kendo-react-conversational-ui",productName:"KendoReact",productCode:"KENDOUIREACT",productCodes:["KENDOUIREACT"],publishDate: 1755016115,version:"11.4.0",licensingDocsUrl:"https://www.telerik.com/kendo-react-ui/components/my-license/"});exports.packageMetadata=e;
|
package/package-metadata.mjs
CHANGED
|
@@ -5,15 +5,15 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
const e = {
|
|
8
|
+
const e = Object.freeze({
|
|
9
9
|
name: "@progress/kendo-react-conversational-ui",
|
|
10
10
|
productName: "KendoReact",
|
|
11
11
|
productCode: "KENDOUIREACT",
|
|
12
12
|
productCodes: ["KENDOUIREACT"],
|
|
13
|
-
publishDate:
|
|
14
|
-
version: "11.4.0
|
|
13
|
+
publishDate: 1755016115,
|
|
14
|
+
version: "11.4.0",
|
|
15
15
|
licensingDocsUrl: "https://www.telerik.com/kendo-react-ui/components/my-license/"
|
|
16
|
-
};
|
|
16
|
+
});
|
|
17
17
|
export {
|
|
18
18
|
e as packageMetadata
|
|
19
19
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@progress/kendo-react-conversational-ui",
|
|
3
|
-
"version": "11.4.0
|
|
3
|
+
"version": "11.4.0",
|
|
4
4
|
"description": "React Chat component allows the user to participate in chat sessions with users or chat bots. KendoReact Conversational UI components",
|
|
5
5
|
"author": "Progress",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
@@ -26,11 +26,11 @@
|
|
|
26
26
|
"sideEffects": false,
|
|
27
27
|
"peerDependencies": {
|
|
28
28
|
"@progress/kendo-licensing": "^1.7.0",
|
|
29
|
-
"@progress/kendo-react-buttons": "11.4.0
|
|
30
|
-
"@progress/kendo-react-common": "11.4.0
|
|
31
|
-
"@progress/kendo-react-intl": "11.4.0
|
|
32
|
-
"@progress/kendo-react-inputs": "11.4.0
|
|
33
|
-
"@progress/kendo-react-layout": "11.4.0
|
|
29
|
+
"@progress/kendo-react-buttons": "11.4.0",
|
|
30
|
+
"@progress/kendo-react-common": "11.4.0",
|
|
31
|
+
"@progress/kendo-react-intl": "11.4.0",
|
|
32
|
+
"@progress/kendo-react-inputs": "11.4.0",
|
|
33
|
+
"@progress/kendo-react-layout": "11.4.0",
|
|
34
34
|
"@progress/kendo-svg-icons": "^4.0.0",
|
|
35
35
|
"react": "^16.8.2 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^19.0.0-rc",
|
|
36
36
|
"react-dom": "^16.8.2 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^19.0.0-rc"
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"package": {
|
|
60
60
|
"productName": "KendoReact",
|
|
61
61
|
"productCode": "KENDOUIREACT",
|
|
62
|
-
"publishDate":
|
|
62
|
+
"publishDate": 1755016115,
|
|
63
63
|
"licensingDocsUrl": "https://www.telerik.com/kendo-react-ui/components/my-license/"
|
|
64
64
|
}
|
|
65
65
|
},
|