@progress/kendo-react-conversational-ui 11.4.0-develop.3 → 11.4.0-develop.5
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 +16 -0
- package/ai-prompt/AIPrompt.js +1 -1
- package/ai-prompt/AIPrompt.mjs +10 -9
- package/ai-prompt/AIPromptContent.js +1 -1
- package/ai-prompt/AIPromptContent.mjs +22 -15
- package/ai-prompt/AIPromptExpander.js +1 -1
- package/ai-prompt/AIPromptExpander.mjs +15 -13
- package/ai-prompt/views/AIPromptCommandsView.js +1 -1
- package/ai-prompt/views/AIPromptCommandsView.mjs +13 -17
- package/ai-prompt/views/AIPromptOutputView.js +1 -1
- package/ai-prompt/views/AIPromptOutputView.mjs +27 -31
- package/ai-prompt/views/AIPromptView.js +2 -1
- package/ai-prompt/views/AIPromptView.mjs +75 -38
- package/ai-prompt/views/constants.js +8 -0
- package/ai-prompt/views/constants.mjs +25 -0
- package/chat/components/SuggestionsGroup.js +8 -0
- package/chat/components/SuggestionsGroup.mjs +32 -0
- package/dist/cdn/js/kendo-react-conversational-ui.js +1 -1
- package/index.d.mts +242 -0
- package/index.d.ts +242 -0
- package/index.js +1 -1
- package/index.mjs +26 -21
- package/inline-ai-prompt/InlineAIPrompt.js +8 -0
- package/inline-ai-prompt/InlineAIPrompt.mjs +175 -0
- package/inline-ai-prompt/InlineAIPromptInput.js +9 -0
- package/inline-ai-prompt/InlineAIPromptInput.mjs +102 -0
- package/inline-ai-prompt/InlineAIPromptPopup.js +8 -0
- package/inline-ai-prompt/InlineAIPromptPopup.mjs +36 -0
- package/package-metadata.js +1 -1
- package/package-metadata.mjs +2 -2
- package/package.json +7 -7
package/index.d.ts
CHANGED
|
@@ -11,7 +11,10 @@ import { CustomComponent } from '@progress/kendo-react-common';
|
|
|
11
11
|
import { default as default_2 } from 'prop-types';
|
|
12
12
|
import { default as default_3 } from 'react';
|
|
13
13
|
import { JSX } from 'react/jsx-runtime';
|
|
14
|
+
import { PopupAnimation } from '@progress/kendo-react-popup';
|
|
15
|
+
import { PopupProps } from '@progress/kendo-react-popup';
|
|
14
16
|
import * as React_2 from 'react';
|
|
17
|
+
import { SpeechToTextButtonProps } from '@progress/kendo-react-buttons';
|
|
15
18
|
import { SVGIcon } from '@progress/kendo-svg-icons';
|
|
16
19
|
import { SVGIcon as SVGIcon_2 } from '@progress/kendo-react-common';
|
|
17
20
|
import { TextAreaProps } from '@progress/kendo-react-inputs';
|
|
@@ -72,6 +75,17 @@ export declare interface AIPromptCardInterface {
|
|
|
72
75
|
actions?: (props: AIPromptOutputInterface) => default_3.ReactNode;
|
|
73
76
|
}
|
|
74
77
|
|
|
78
|
+
declare interface AIPromptCardInterface_2 {
|
|
79
|
+
/**
|
|
80
|
+
* Custom template for AIPromptCard body.
|
|
81
|
+
*/
|
|
82
|
+
body?: (props: InlineAIPromptOutputInterface) => default_3.ReactNode;
|
|
83
|
+
/**
|
|
84
|
+
* Custom template for AIPromptCard actions.
|
|
85
|
+
*/
|
|
86
|
+
actions?: (props: InlineAIPromptOutputInterface) => default_3.ReactNode;
|
|
87
|
+
}
|
|
88
|
+
|
|
75
89
|
/**
|
|
76
90
|
* The props of the AIPromptCommandsView component.
|
|
77
91
|
*/
|
|
@@ -325,6 +339,13 @@ export declare interface AIPromptProps extends default_3.HTMLAttributes<HTMLElem
|
|
|
325
339
|
* ```
|
|
326
340
|
*/
|
|
327
341
|
streaming?: boolean;
|
|
342
|
+
/**
|
|
343
|
+
* If true, the prompt is in a loading state.
|
|
344
|
+
* ```jsx
|
|
345
|
+
* <AIPrompt loading={true} />
|
|
346
|
+
* ```
|
|
347
|
+
*/
|
|
348
|
+
loading?: boolean;
|
|
328
349
|
}
|
|
329
350
|
|
|
330
351
|
/**
|
|
@@ -370,6 +391,13 @@ export declare interface AIPromptViewProps {
|
|
|
370
391
|
* The suggestions that will be displayed in the prompt view. See example [here]({% slug suggestions_aiprompt %}).
|
|
371
392
|
*/
|
|
372
393
|
promptSuggestions?: string[];
|
|
394
|
+
/**
|
|
395
|
+
* Show speech to text button in input. When true, shows the button with default settings.
|
|
396
|
+
* When an object is provided, passes those props directly to the SpeechToTextButton component.
|
|
397
|
+
*
|
|
398
|
+
* @default false
|
|
399
|
+
*/
|
|
400
|
+
enableSpeechToText?: boolean | SpeechToTextButtonProps;
|
|
373
401
|
}
|
|
374
402
|
|
|
375
403
|
/**
|
|
@@ -674,6 +702,18 @@ export declare interface ChatState {
|
|
|
674
702
|
isFirstRender: boolean;
|
|
675
703
|
}
|
|
676
704
|
|
|
705
|
+
/**
|
|
706
|
+
* Represents the structure of a chat suggestion item that can be displayed above the message input.
|
|
707
|
+
*
|
|
708
|
+
* @interface ChatSuggestion
|
|
709
|
+
*/
|
|
710
|
+
export declare interface ChatSuggestion {
|
|
711
|
+
id: string | number;
|
|
712
|
+
text: string;
|
|
713
|
+
description?: string;
|
|
714
|
+
disabled?: boolean;
|
|
715
|
+
}
|
|
716
|
+
|
|
677
717
|
/**
|
|
678
718
|
* The arguments for the `toolbaractionexecute` event of the Chat.
|
|
679
719
|
*/
|
|
@@ -710,6 +750,11 @@ export declare interface CommandItemInterface {
|
|
|
710
750
|
* Specifies the name of the SVG icon that will be rendered for the command.
|
|
711
751
|
*/
|
|
712
752
|
svgIcon?: SVGIcon_2;
|
|
753
|
+
/**
|
|
754
|
+
* Optional prompt function that takes selected text and returns a formatted prompt.
|
|
755
|
+
* This is used by default commands and can be used by custom commands.
|
|
756
|
+
*/
|
|
757
|
+
prompt?: (selection: string) => string;
|
|
713
758
|
}
|
|
714
759
|
|
|
715
760
|
/**
|
|
@@ -789,6 +834,173 @@ export declare interface HeroCardProps {
|
|
|
789
834
|
imageMaxWidth?: string | number;
|
|
790
835
|
}
|
|
791
836
|
|
|
837
|
+
export declare const InlineAIPrompt: (props: InlineAIPromptProps) => JSX.Element;
|
|
838
|
+
|
|
839
|
+
export declare interface InlineAIPromptOutputInterface {
|
|
840
|
+
/**
|
|
841
|
+
* Example usage of the `id` property:
|
|
842
|
+
* ```jsx
|
|
843
|
+
* const output = { id: 1, responseContent: 'Generated content' };
|
|
844
|
+
* ```
|
|
845
|
+
*/
|
|
846
|
+
id: string | number;
|
|
847
|
+
/**
|
|
848
|
+
* Example usage of the `prompt` property:
|
|
849
|
+
* ```jsx
|
|
850
|
+
* const output = { prompt: 'User prompt', responseContent: 'Generated content' };
|
|
851
|
+
* ```
|
|
852
|
+
*/
|
|
853
|
+
prompt?: string;
|
|
854
|
+
/**
|
|
855
|
+
* Example usage of the `responseContent` property:
|
|
856
|
+
* ```jsx
|
|
857
|
+
* const output = { responseContent: 'Generated content' };
|
|
858
|
+
* ```
|
|
859
|
+
*/
|
|
860
|
+
responseContent: string;
|
|
861
|
+
}
|
|
862
|
+
|
|
863
|
+
declare interface InlineAIPromptPopupProps {
|
|
864
|
+
/**
|
|
865
|
+
* Controls the visibility of the popup.
|
|
866
|
+
*
|
|
867
|
+
* @default false
|
|
868
|
+
*/
|
|
869
|
+
show?: boolean;
|
|
870
|
+
/**
|
|
871
|
+
* The element that serves as an anchor for the popup.
|
|
872
|
+
*/
|
|
873
|
+
anchor?: HTMLElement | null;
|
|
874
|
+
/**
|
|
875
|
+
* Fires when the popup is opened.
|
|
876
|
+
*/
|
|
877
|
+
onOpen?: (event: {
|
|
878
|
+
target: any;
|
|
879
|
+
}) => void;
|
|
880
|
+
/**
|
|
881
|
+
* Fires when the popup is closed.
|
|
882
|
+
*/
|
|
883
|
+
onClose?: (event: {
|
|
884
|
+
target: any;
|
|
885
|
+
}) => void;
|
|
886
|
+
/**
|
|
887
|
+
* Controls the animation of the popup.
|
|
888
|
+
*
|
|
889
|
+
* @default true
|
|
890
|
+
*/
|
|
891
|
+
animate?: boolean | PopupAnimation;
|
|
892
|
+
/**
|
|
893
|
+
* The container element where the popup will be rendered.
|
|
894
|
+
* If not specified, the popup will be rendered in the document body.
|
|
895
|
+
*/
|
|
896
|
+
appendTo?: HTMLElement;
|
|
897
|
+
/**
|
|
898
|
+
* Object which passes props directly to the Popup component.
|
|
899
|
+
*/
|
|
900
|
+
popupOptions?: PopupProps;
|
|
901
|
+
/**
|
|
902
|
+
* The content to render inside the popup.
|
|
903
|
+
*/
|
|
904
|
+
children?: default_3.ReactNode;
|
|
905
|
+
/**
|
|
906
|
+
* Additional CSS styles for the popup content.
|
|
907
|
+
*/
|
|
908
|
+
style?: default_3.CSSProperties;
|
|
909
|
+
}
|
|
910
|
+
|
|
911
|
+
export declare interface InlineAIPromptProps extends Omit<default_3.HTMLAttributes<HTMLElement>, 'onCopy'>, InlineAIPromptPopupProps {
|
|
912
|
+
/**
|
|
913
|
+
* Example usage of the `style` property:
|
|
914
|
+
* ```jsx
|
|
915
|
+
* <InlineAIPrompt style={{ backgroundColor: 'lightblue' }} />
|
|
916
|
+
* ```
|
|
917
|
+
*/
|
|
918
|
+
style?: default_3.CSSProperties;
|
|
919
|
+
/**
|
|
920
|
+
* The collection of outputs to display as cards
|
|
921
|
+
*/
|
|
922
|
+
outputs?: InlineAIPromptOutputInterface[];
|
|
923
|
+
/**
|
|
924
|
+
* Represents a template that allows you to define custom Card fields for:
|
|
925
|
+
* header, body, actions
|
|
926
|
+
* The custom fields will override the default one.
|
|
927
|
+
*/
|
|
928
|
+
outputCard?: AIPromptCardInterface_2;
|
|
929
|
+
/**
|
|
930
|
+
* Placeholder text for the prompt input
|
|
931
|
+
*/
|
|
932
|
+
promptPlaceholder?: string;
|
|
933
|
+
/**
|
|
934
|
+
* The initial value of the prompt input
|
|
935
|
+
*/
|
|
936
|
+
promptValue?: string;
|
|
937
|
+
/**
|
|
938
|
+
* Callback when user submits a prompt
|
|
939
|
+
*/
|
|
940
|
+
onPromptRequest?: (prompt: string, outputItem?: InlineAIPromptOutputInterface) => void;
|
|
941
|
+
/**
|
|
942
|
+
* Specifies the callback for cancel action.
|
|
943
|
+
*/
|
|
944
|
+
onPromptCancel?: () => void;
|
|
945
|
+
/**
|
|
946
|
+
* Fires each time the user clicks Copy button in the card.
|
|
947
|
+
*/
|
|
948
|
+
onCopy?: (output: InlineAIPromptOutputInterface) => void;
|
|
949
|
+
/**
|
|
950
|
+
* Fires each time the user clicks Discard button in the card.
|
|
951
|
+
*/
|
|
952
|
+
onDiscard?: (output: InlineAIPromptOutputInterface) => void;
|
|
953
|
+
/**
|
|
954
|
+
* The collection of output actions that will be rendered in the card actions.
|
|
955
|
+
* If not specified, default actions (copy, discard) will be used.
|
|
956
|
+
* You can override built-in actions.
|
|
957
|
+
*/
|
|
958
|
+
outputActions?: OutputActionInterface[];
|
|
959
|
+
/**
|
|
960
|
+
* Fires when an action command is executed.
|
|
961
|
+
* Built-in actions (copy, discard) are handled internally by the component.
|
|
962
|
+
* All other actions are handled by this callback.
|
|
963
|
+
*/
|
|
964
|
+
onOutputAction?: (command: OutputActionInterface, output: InlineAIPromptOutputInterface) => void;
|
|
965
|
+
/**
|
|
966
|
+
* Accepts a custom component that can be used to render the prompt input.
|
|
967
|
+
*/
|
|
968
|
+
promptInput?: CustomComponent<TextAreaProps>;
|
|
969
|
+
/**
|
|
970
|
+
* Accepts a custom component that can be used to render the generate button.
|
|
971
|
+
*/
|
|
972
|
+
generateButton?: CustomComponent<ButtonProps>;
|
|
973
|
+
/**
|
|
974
|
+
* Show speech to text button in input. When true, shows the button with default settings.
|
|
975
|
+
* When an object is provided, passes those props directly to the SpeechToTextButton component.
|
|
976
|
+
*
|
|
977
|
+
* @default false
|
|
978
|
+
*/
|
|
979
|
+
enableSpeechToText?: boolean | SpeechToTextButtonProps;
|
|
980
|
+
/**
|
|
981
|
+
* Specifies if the content is being streamed.
|
|
982
|
+
*/
|
|
983
|
+
streaming?: boolean;
|
|
984
|
+
/**
|
|
985
|
+
* The collection of commands that will be rendered in the context menu.
|
|
986
|
+
* If not specified, default AI text editing commands will be used.
|
|
987
|
+
*/
|
|
988
|
+
commands?: CommandInterface[];
|
|
989
|
+
/**
|
|
990
|
+
* The width of the component.
|
|
991
|
+
*/
|
|
992
|
+
width?: number | string;
|
|
993
|
+
/**
|
|
994
|
+
* The height of the component.
|
|
995
|
+
*/
|
|
996
|
+
height?: number | string;
|
|
997
|
+
/**
|
|
998
|
+
* Fires when a command from the context menu is executed.
|
|
999
|
+
* Exposes the selected command and current prompt value as event data.
|
|
1000
|
+
*/
|
|
1001
|
+
onCommandExecute?: (command: CommandItemInterface) => void;
|
|
1002
|
+
}
|
|
1003
|
+
|
|
792
1004
|
/**
|
|
793
1005
|
* Represents a Chat message.
|
|
794
1006
|
*
|
|
@@ -849,6 +1061,29 @@ export declare interface Message {
|
|
|
849
1061
|
export declare interface MessageModel extends Message, Selectable {
|
|
850
1062
|
}
|
|
851
1063
|
|
|
1064
|
+
export declare interface OutputActionInterface {
|
|
1065
|
+
/**
|
|
1066
|
+
* The unique identifier for the action command
|
|
1067
|
+
*/
|
|
1068
|
+
id: string;
|
|
1069
|
+
/**
|
|
1070
|
+
* The text to display on the button
|
|
1071
|
+
*/
|
|
1072
|
+
text: string;
|
|
1073
|
+
/**
|
|
1074
|
+
* The SVG icon to display on the button
|
|
1075
|
+
*/
|
|
1076
|
+
svgIcon?: any;
|
|
1077
|
+
/**
|
|
1078
|
+
* The theme color of the button
|
|
1079
|
+
*/
|
|
1080
|
+
themeColor?: ButtonProps['themeColor'];
|
|
1081
|
+
/**
|
|
1082
|
+
* The title attribute for the button (tooltip)
|
|
1083
|
+
*/
|
|
1084
|
+
title?: string;
|
|
1085
|
+
}
|
|
1086
|
+
|
|
852
1087
|
/**
|
|
853
1088
|
* Specifies the default values for Output view Toolbar.
|
|
854
1089
|
*/
|
|
@@ -871,6 +1106,13 @@ declare interface Selectable {
|
|
|
871
1106
|
selectionIndex: number;
|
|
872
1107
|
}
|
|
873
1108
|
|
|
1109
|
+
export declare const SuggestionGroup: React_2.FC<SuggestionGroupProps>;
|
|
1110
|
+
|
|
1111
|
+
declare interface SuggestionGroupProps {
|
|
1112
|
+
suggestions: ChatSuggestion[];
|
|
1113
|
+
onSuggestionClick: (event: React_2.MouseEvent<HTMLSpanElement>, suggestion: ChatSuggestion) => void;
|
|
1114
|
+
}
|
|
1115
|
+
|
|
874
1116
|
/**
|
|
875
1117
|
* Represents a participant in a Chat conversation.
|
|
876
1118
|
*/
|
package/index.js
CHANGED
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
8
|
"use client";
|
|
9
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
9
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./components/ChatMessage.js"),r=require("./components/Chat.js"),o=require("./chat/components/SuggestionsGroup.js"),i=require("./components/templates/HeroCard.js"),n=require("./ai-prompt/AIPrompt.js"),m=require("./ai-prompt/AIPromptHeader.js"),p=require("./ai-prompt/AIPromptFooter.js"),s=require("./ai-prompt/AIPromptContent.js"),u=require("./ai-prompt/views/AIPromptView.js"),a=require("./ai-prompt/views/AIPromptOutputView.js"),I=require("./ai-prompt/views/AIPromptCommandsView.js"),P=require("./ai-prompt/views/AIPromptViewRender.js"),A=require("./inline-ai-prompt/InlineAIPrompt.js"),e=require("./ai-prompt/views/constants.js");exports.ChatMessage=t.ChatMessage;exports.Chat=r.Chat;exports.SuggestionGroup=o.SuggestionGroup;exports.HeroCard=i.HeroCard;exports.AIPrompt=n.AIPrompt;exports.PromptHeader=m.PromptHeader;exports.AIPromptFooter=p.AIPromptFooter;exports.AIPromptContent=s.AIPromptContent;exports.AIPromptView=u.AIPromptView;exports.AIPromptOutputView=a.AIPromptOutputView;exports.AIPromptCommandsView=I.AIPromptCommandsView;exports.AIPromptViewRender=P.AIPromptViewRender;exports.InlineAIPrompt=A.InlineAIPrompt;exports.commandsViewDefaults=e.commandsViewDefaults;exports.outputViewDefaults=e.outputViewDefaults;exports.promptViewDefaults=e.promptViewDefaults;
|
package/index.mjs
CHANGED
|
@@ -8,28 +8,33 @@
|
|
|
8
8
|
"use client";
|
|
9
9
|
import { ChatMessage as t } from "./components/ChatMessage.mjs";
|
|
10
10
|
import { Chat as m } from "./components/Chat.mjs";
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
11
|
+
import { SuggestionGroup as f } from "./chat/components/SuggestionsGroup.mjs";
|
|
12
|
+
import { HeroCard as a } from "./components/templates/HeroCard.mjs";
|
|
13
|
+
import { AIPrompt as u } from "./ai-prompt/AIPrompt.mjs";
|
|
14
|
+
import { PromptHeader as P } from "./ai-prompt/AIPromptHeader.mjs";
|
|
15
|
+
import { AIPromptFooter as s } from "./ai-prompt/AIPromptFooter.mjs";
|
|
16
|
+
import { AIPromptContent as w } from "./ai-prompt/AIPromptContent.mjs";
|
|
17
|
+
import { AIPromptView as d } from "./ai-prompt/views/AIPromptView.mjs";
|
|
18
|
+
import { AIPromptOutputView as l } from "./ai-prompt/views/AIPromptOutputView.mjs";
|
|
19
|
+
import { AIPromptCommandsView as D } from "./ai-prompt/views/AIPromptCommandsView.mjs";
|
|
20
|
+
import { AIPromptViewRender as H } from "./ai-prompt/views/AIPromptViewRender.mjs";
|
|
21
|
+
import { InlineAIPrompt as F } from "./inline-ai-prompt/InlineAIPrompt.mjs";
|
|
22
|
+
import { commandsViewDefaults as M, outputViewDefaults as O, promptViewDefaults as R } from "./ai-prompt/views/constants.mjs";
|
|
20
23
|
export {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
u as AIPrompt,
|
|
25
|
+
D as AIPromptCommandsView,
|
|
26
|
+
w as AIPromptContent,
|
|
27
|
+
s as AIPromptFooter,
|
|
28
|
+
l as AIPromptOutputView,
|
|
29
|
+
d as AIPromptView,
|
|
30
|
+
H as AIPromptViewRender,
|
|
28
31
|
m as Chat,
|
|
29
32
|
t as ChatMessage,
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
a as HeroCard,
|
|
34
|
+
F as InlineAIPrompt,
|
|
35
|
+
P as PromptHeader,
|
|
36
|
+
f as SuggestionGroup,
|
|
37
|
+
M as commandsViewDefaults,
|
|
38
|
+
O as outputViewDefaults,
|
|
39
|
+
R as promptViewDefaults
|
|
35
40
|
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2025 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react"),d=require("@progress/kendo-react-layout"),x=require("@progress/kendo-react-buttons"),re=require("@progress/kendo-react-inputs"),I=require("@progress/kendo-svg-icons"),ae=require("@progress/kendo-react-common"),le=require("./InlineAIPromptPopup.js"),ce=require("./InlineAIPromptInput.js"),ie=require("../ai-prompt/AIPromptContent.js"),de=P=>{const{outputs:m=[],outputCard:b,promptInput:M=re.TextArea,generateButton:S=x.Button,promptPlaceholder:q="Ask or generate content with AI...",promptValue:w,onPromptRequest:O,onCopy:p,onDiscard:u,outputActions:A,onOutputAction:C,enableSpeechToText:R=!1,streaming:r,onPromptCancel:a,show:T=!1,anchor:B,width:l,height:c,onOpen:D,onClose:i,animate:N=!0,appendTo:F,commands:y,onCommandExecute:k,style:K,className:$,popupOptions:j={},...z}=P,[V,g]=t.useState(""),[_,h]=t.useState(!1),[G,H]=t.useState({left:0,top:0}),f=t.useRef(null),{body:E,actions:v}=b||{},J=[{id:"copy",text:"Copy",svgIcon:I.copyIcon,themeColor:"primary",title:"Copy"},{id:"discard",text:"Discard",svgIcon:I.cancelOutlineIcon,themeColor:"base",title:"Discard"}],Q=A||J,U=e=>{e.responseContent&&(navigator.clipboard.writeText(e.responseContent),g(e.id),setTimeout(()=>g(""),1e3)),p==null||p(e)},W=e=>{u==null||u(e)},X=(e,n)=>{switch(e.id){case"copy":U(n);break;case"discard":W(n);break;default:C==null||C(e,n);break}},Y=e=>{if(!f.current)return;const n=f.current.getBoundingClientRect();H({left:n.left,top:n.bottom}),h(!0)},Z=()=>{h(!1)},L=e=>{h(!1),k&&k(e)},ee=e=>e==null?void 0:e.map(n=>({text:n.text,svgIcon:n.svgIcon,data:n,items:n.children?n.children.map(o=>({text:o.text,data:o})):void 0})),te=t.useCallback(e=>{e.key==="Escape"&&(r&&a?a():!r&&i&&i({target:null}))},[r,a,i]),ne={...K,...l&&{width:l},...c&&{height:c}},oe={...l&&{width:l},...c&&{height:c}},se=t.createElement("div",{className:ae.classNames("k-prompt",$),style:ne,onKeyDown:te,...z},t.createElement(ie.AIPromptContent,{ref:f},m&&m.length>0&&t.createElement("div",{className:"k-card-list"},m.map((e,n)=>t.createElement(d.Card,{key:`${e.id}_${n}`},t.createElement(d.CardBody,null,E?E(e):e.responseContent),t.createElement(d.CardActions,null,v?v(e):t.createElement(t.Fragment,null,Q.map(o=>{var s;return t.createElement(x.Button,{key:o.id,size:"medium",themeColor:o.themeColor||"primary",fillMode:"flat",rounded:"medium",title:(s=o.title)!=null?s:o.text,svgIcon:o.id==="copy"&&V===e.id?I.checkIcon:o.svgIcon,"aria-hidden":"true",onClick:()=>X(o,e)},o.text)})))))),t.createElement(ce.InlineAIPromptInput,{promptValue:w,placeholder:q,onPromptRequest:O,onMenuClick:Y,onPromptCancel:a,promptInput:M,generateButton:S,enableSpeechToText:R,streaming:r,commands:y})));return t.createElement(t.Fragment,null,t.createElement(le.InlineAIPromptPopup,{show:T,anchor:B,onOpen:D,onClose:i,animate:N,appendTo:F,popupOptions:j,style:oe},se),t.createElement(d.ContextMenu,{show:_,offset:G,onClose:Z,items:ee(y),onSelect:e=>{var o,s;const n=(o=e.item)==null?void 0:o.data;n&&!((s=n.children)!=null&&s.length)&&L(n)}}))};exports.InlineAIPrompt=de;
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2025 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
import t from "react";
|
|
9
|
+
import { Card as ne, CardBody as oe, CardActions as re, ContextMenu as ae } from "@progress/kendo-react-layout";
|
|
10
|
+
import { Button as x } from "@progress/kendo-react-buttons";
|
|
11
|
+
import { TextArea as se } from "@progress/kendo-react-inputs";
|
|
12
|
+
import { checkIcon as le, copyIcon as ce, cancelOutlineIcon as me } from "@progress/kendo-svg-icons";
|
|
13
|
+
import { classNames as ie } from "@progress/kendo-react-common";
|
|
14
|
+
import { InlineAIPromptPopup as de } from "./InlineAIPromptPopup.mjs";
|
|
15
|
+
import { InlineAIPromptInput as pe } from "./InlineAIPromptInput.mjs";
|
|
16
|
+
import { AIPromptContent as fe } from "../ai-prompt/AIPromptContent.mjs";
|
|
17
|
+
const be = (E) => {
|
|
18
|
+
const {
|
|
19
|
+
outputs: i = [],
|
|
20
|
+
outputCard: v,
|
|
21
|
+
promptInput: b = se,
|
|
22
|
+
generateButton: M = x,
|
|
23
|
+
promptPlaceholder: w = "Ask or generate content with AI...",
|
|
24
|
+
promptValue: O,
|
|
25
|
+
onPromptRequest: S,
|
|
26
|
+
onCopy: d,
|
|
27
|
+
onDiscard: p,
|
|
28
|
+
outputActions: P,
|
|
29
|
+
onOutputAction: f,
|
|
30
|
+
enableSpeechToText: T = !1,
|
|
31
|
+
streaming: a,
|
|
32
|
+
onPromptCancel: s,
|
|
33
|
+
show: A = !1,
|
|
34
|
+
anchor: B,
|
|
35
|
+
width: l,
|
|
36
|
+
height: c,
|
|
37
|
+
onOpen: D,
|
|
38
|
+
onClose: m,
|
|
39
|
+
animate: R = !0,
|
|
40
|
+
appendTo: N,
|
|
41
|
+
commands: u,
|
|
42
|
+
onCommandExecute: y,
|
|
43
|
+
style: _,
|
|
44
|
+
className: F,
|
|
45
|
+
popupOptions: K = {},
|
|
46
|
+
...$
|
|
47
|
+
} = E, [q, I] = t.useState(""), [z, C] = t.useState(!1), [V, j] = t.useState({
|
|
48
|
+
left: 0,
|
|
49
|
+
top: 0
|
|
50
|
+
}), h = t.useRef(null), { body: g, actions: k } = v || {}, G = P || [
|
|
51
|
+
{
|
|
52
|
+
id: "copy",
|
|
53
|
+
text: "Copy",
|
|
54
|
+
svgIcon: ce,
|
|
55
|
+
themeColor: "primary",
|
|
56
|
+
title: "Copy"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
id: "discard",
|
|
60
|
+
text: "Discard",
|
|
61
|
+
svgIcon: me,
|
|
62
|
+
themeColor: "base",
|
|
63
|
+
title: "Discard"
|
|
64
|
+
}
|
|
65
|
+
], H = (e) => {
|
|
66
|
+
e.responseContent && (navigator.clipboard.writeText(e.responseContent), I(e.id), setTimeout(() => I(""), 1e3)), d == null || d(e);
|
|
67
|
+
}, J = (e) => {
|
|
68
|
+
p == null || p(e);
|
|
69
|
+
}, Q = (e, n) => {
|
|
70
|
+
switch (e.id) {
|
|
71
|
+
case "copy":
|
|
72
|
+
H(n);
|
|
73
|
+
break;
|
|
74
|
+
case "discard":
|
|
75
|
+
J(n);
|
|
76
|
+
break;
|
|
77
|
+
default:
|
|
78
|
+
f == null || f(e, n);
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
}, U = (e) => {
|
|
82
|
+
if (!h.current)
|
|
83
|
+
return;
|
|
84
|
+
const n = h.current.getBoundingClientRect();
|
|
85
|
+
j({
|
|
86
|
+
left: n.left,
|
|
87
|
+
top: n.bottom
|
|
88
|
+
}), C(!0);
|
|
89
|
+
}, W = () => {
|
|
90
|
+
C(!1);
|
|
91
|
+
}, X = (e) => {
|
|
92
|
+
C(!1), y && y(e);
|
|
93
|
+
}, Y = (e) => e == null ? void 0 : e.map((n) => ({
|
|
94
|
+
text: n.text,
|
|
95
|
+
svgIcon: n.svgIcon,
|
|
96
|
+
data: n,
|
|
97
|
+
items: n.children ? n.children.map((o) => ({
|
|
98
|
+
text: o.text,
|
|
99
|
+
data: o
|
|
100
|
+
})) : void 0
|
|
101
|
+
})), Z = t.useCallback(
|
|
102
|
+
(e) => {
|
|
103
|
+
e.key === "Escape" && (a && s ? s() : !a && m && m({ target: null }));
|
|
104
|
+
},
|
|
105
|
+
[a, s, m]
|
|
106
|
+
), L = {
|
|
107
|
+
..._,
|
|
108
|
+
...l && { width: l },
|
|
109
|
+
...c && { height: c }
|
|
110
|
+
}, ee = {
|
|
111
|
+
...l && { width: l },
|
|
112
|
+
...c && { height: c }
|
|
113
|
+
}, te = /* @__PURE__ */ t.createElement("div", { className: ie("k-prompt", F), style: L, onKeyDown: Z, ...$ }, /* @__PURE__ */ t.createElement(fe, { ref: h }, i && i.length > 0 && /* @__PURE__ */ t.createElement("div", { className: "k-card-list" }, i.map((e, n) => /* @__PURE__ */ t.createElement(ne, { key: `${e.id}_${n}` }, /* @__PURE__ */ t.createElement(oe, null, g ? g(e) : e.responseContent), /* @__PURE__ */ t.createElement(re, null, k ? k(e) : /* @__PURE__ */ t.createElement(t.Fragment, null, G.map((o) => {
|
|
114
|
+
var r;
|
|
115
|
+
return /* @__PURE__ */ t.createElement(
|
|
116
|
+
x,
|
|
117
|
+
{
|
|
118
|
+
key: o.id,
|
|
119
|
+
size: "medium",
|
|
120
|
+
themeColor: o.themeColor || "primary",
|
|
121
|
+
fillMode: "flat",
|
|
122
|
+
rounded: "medium",
|
|
123
|
+
title: (r = o.title) != null ? r : o.text,
|
|
124
|
+
svgIcon: o.id === "copy" && q === e.id ? le : o.svgIcon,
|
|
125
|
+
"aria-hidden": "true",
|
|
126
|
+
onClick: () => Q(o, e)
|
|
127
|
+
},
|
|
128
|
+
o.text
|
|
129
|
+
);
|
|
130
|
+
})))))), /* @__PURE__ */ t.createElement(
|
|
131
|
+
pe,
|
|
132
|
+
{
|
|
133
|
+
promptValue: O,
|
|
134
|
+
placeholder: w,
|
|
135
|
+
onPromptRequest: S,
|
|
136
|
+
onMenuClick: U,
|
|
137
|
+
onPromptCancel: s,
|
|
138
|
+
promptInput: b,
|
|
139
|
+
generateButton: M,
|
|
140
|
+
enableSpeechToText: T,
|
|
141
|
+
streaming: a,
|
|
142
|
+
commands: u
|
|
143
|
+
}
|
|
144
|
+
)));
|
|
145
|
+
return /* @__PURE__ */ t.createElement(t.Fragment, null, /* @__PURE__ */ t.createElement(
|
|
146
|
+
de,
|
|
147
|
+
{
|
|
148
|
+
show: A,
|
|
149
|
+
anchor: B,
|
|
150
|
+
onOpen: D,
|
|
151
|
+
onClose: m,
|
|
152
|
+
animate: R,
|
|
153
|
+
appendTo: N,
|
|
154
|
+
popupOptions: K,
|
|
155
|
+
style: ee
|
|
156
|
+
},
|
|
157
|
+
te
|
|
158
|
+
), /* @__PURE__ */ t.createElement(
|
|
159
|
+
ae,
|
|
160
|
+
{
|
|
161
|
+
show: z,
|
|
162
|
+
offset: V,
|
|
163
|
+
onClose: W,
|
|
164
|
+
items: Y(u),
|
|
165
|
+
onSelect: (e) => {
|
|
166
|
+
var o, r;
|
|
167
|
+
const n = (o = e.item) == null ? void 0 : o.data;
|
|
168
|
+
n && !((r = n.children) != null && r.length) && X(n);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
));
|
|
172
|
+
};
|
|
173
|
+
export {
|
|
174
|
+
be as InlineAIPrompt
|
|
175
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2025 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react"),P=require("@progress/kendo-react-buttons"),r=require("@progress/kendo-react-inputs"),c=require("@progress/kendo-svg-icons"),u=require("@progress/kendo-react-common"),G=({placeholder:v="Ask or generate content with AI...",promptValue:B,onMenuClick:S,promptInput:h=r.TextArea,generateButton:A,enableSpeechToText:s=!1,streaming:e=!1,commands:i,onPromptRequest:m,onPromptCancel:E})=>{const[o,p]=t.useState(B||""),[y,d]=u.useCustomComponent(A),[x,f]=u.useCustomComponent(h),b={svgIcon:e?c.stopSmIcon:c.paperPlaneIcon,active:e,title:"Send Button","aria-label":"Send Button",disabled:!o.trim()&&!e,"aria-disabled":!o.trim()&&!e},w={placeholder:v,className:"!k-flex-row",autoSize:!0,rows:1},I=i&&i.length>0,R=Object.keys(d).length>0?d:b,N=Object.keys(f).length>0?f:w,k=n=>{const{isFinal:l,alternatives:C}=n;if(l&&C.length>0){const q=C[0].transcript,M=(()=>{const a=o,V=a&&!a.endsWith(" ")&&!a.endsWith(`
|
|
9
|
+
`);return a+(V?" ":"")+q})();p(M)}},j=n=>{const l=n.target.value;p(l)},g=()=>{o.trim()&&m&&m(o.trim())};return t.createElement(x,{value:o,onChange:j,onKeyDown:n=>{n.key==="Enter"&&!n.shiftKey&&(n.preventDefault(),g())},prefix:I||s?t.createElement(t.Fragment,null,t.createElement(r.InputPrefix,{className:"!k-align-items-start"},I&&t.createElement(P.Button,{"aria-label":"Commands Button",title:"Commands Button",fillMode:"flat",svgIcon:c.menuIcon,onClick:S}),s&&t.createElement(P.SpeechToTextButton,{fillMode:"flat",...typeof s=="object"?{...s,onResult:s.onResult||k}:{onResult:k}})),t.createElement(r.InputSeparator,null)):void 0,suffix:t.createElement(r.InputSuffix,{className:"!k-align-items-start"},t.createElement(y,{className:u.classNames("k-prompt-send",{"k-generating":e,"k-active":e}),fillMode:"flat",onClick:e?E:g,...R})),...N})};exports.InlineAIPromptInput=G;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2025 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
import t from "react";
|
|
9
|
+
import { Button as G, SpeechToTextButton as M } from "@progress/kendo-react-buttons";
|
|
10
|
+
import { InputPrefix as R, InputSeparator as D, InputSuffix as F, TextArea as K } from "@progress/kendo-react-inputs";
|
|
11
|
+
import { stopSmIcon as O, paperPlaneIcon as W, menuIcon as _ } from "@progress/kendo-svg-icons";
|
|
12
|
+
import { useCustomComponent as I, classNames as z } from "@progress/kendo-react-common";
|
|
13
|
+
const U = ({
|
|
14
|
+
placeholder: g = "Ask or generate content with AI...",
|
|
15
|
+
promptValue: h,
|
|
16
|
+
onMenuClick: B,
|
|
17
|
+
promptInput: P = K,
|
|
18
|
+
generateButton: v,
|
|
19
|
+
enableSpeechToText: a = !1,
|
|
20
|
+
streaming: e = !1,
|
|
21
|
+
commands: l,
|
|
22
|
+
onPromptRequest: c,
|
|
23
|
+
onPromptCancel: C
|
|
24
|
+
}) => {
|
|
25
|
+
const [o, i] = t.useState(h || ""), [E, u] = I(
|
|
26
|
+
v
|
|
27
|
+
), [x, m] = I(P), A = {
|
|
28
|
+
svgIcon: e ? O : W,
|
|
29
|
+
active: e,
|
|
30
|
+
title: "Send Button",
|
|
31
|
+
"aria-label": "Send Button",
|
|
32
|
+
disabled: !o.trim() && !e,
|
|
33
|
+
"aria-disabled": !o.trim() && !e
|
|
34
|
+
}, S = {
|
|
35
|
+
placeholder: g,
|
|
36
|
+
className: "!k-flex-row",
|
|
37
|
+
autoSize: !0,
|
|
38
|
+
rows: 1
|
|
39
|
+
}, f = l && l.length > 0, w = Object.keys(u).length > 0 ? u : A, y = Object.keys(m).length > 0 ? m : S, p = (n) => {
|
|
40
|
+
const { isFinal: s, alternatives: k } = n;
|
|
41
|
+
if (s && k.length > 0) {
|
|
42
|
+
const b = k[0].transcript, V = (() => {
|
|
43
|
+
const r = o, j = r && !r.endsWith(" ") && !r.endsWith(`
|
|
44
|
+
`);
|
|
45
|
+
return r + (j ? " " : "") + b;
|
|
46
|
+
})();
|
|
47
|
+
i(V);
|
|
48
|
+
}
|
|
49
|
+
}, N = (n) => {
|
|
50
|
+
const s = n.target.value;
|
|
51
|
+
i(s);
|
|
52
|
+
}, d = () => {
|
|
53
|
+
o.trim() && c && c(o.trim());
|
|
54
|
+
};
|
|
55
|
+
return /* @__PURE__ */ t.createElement(
|
|
56
|
+
x,
|
|
57
|
+
{
|
|
58
|
+
value: o,
|
|
59
|
+
onChange: N,
|
|
60
|
+
onKeyDown: (n) => {
|
|
61
|
+
n.key === "Enter" && !n.shiftKey && (n.preventDefault(), d());
|
|
62
|
+
},
|
|
63
|
+
prefix: f || a ? /* @__PURE__ */ t.createElement(t.Fragment, null, /* @__PURE__ */ t.createElement(R, { className: "!k-align-items-start" }, f && /* @__PURE__ */ t.createElement(
|
|
64
|
+
G,
|
|
65
|
+
{
|
|
66
|
+
"aria-label": "Commands Button",
|
|
67
|
+
title: "Commands Button",
|
|
68
|
+
fillMode: "flat",
|
|
69
|
+
svgIcon: _,
|
|
70
|
+
onClick: B
|
|
71
|
+
}
|
|
72
|
+
), a && /* @__PURE__ */ t.createElement(
|
|
73
|
+
M,
|
|
74
|
+
{
|
|
75
|
+
fillMode: "flat",
|
|
76
|
+
...typeof a == "object" ? {
|
|
77
|
+
...a,
|
|
78
|
+
onResult: a.onResult || p
|
|
79
|
+
} : {
|
|
80
|
+
onResult: p
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
)), /* @__PURE__ */ t.createElement(D, null)) : void 0,
|
|
84
|
+
suffix: /* @__PURE__ */ t.createElement(F, { className: "!k-align-items-start" }, /* @__PURE__ */ t.createElement(
|
|
85
|
+
E,
|
|
86
|
+
{
|
|
87
|
+
className: z("k-prompt-send", {
|
|
88
|
+
"k-generating": e,
|
|
89
|
+
"k-active": e
|
|
90
|
+
}),
|
|
91
|
+
fillMode: "flat",
|
|
92
|
+
onClick: e ? C : d,
|
|
93
|
+
...w
|
|
94
|
+
}
|
|
95
|
+
)),
|
|
96
|
+
...y
|
|
97
|
+
}
|
|
98
|
+
);
|
|
99
|
+
};
|
|
100
|
+
export {
|
|
101
|
+
U as InlineAIPromptInput
|
|
102
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2025 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react"),P=require("@progress/kendo-react-popup"),a=({show:e=!1,anchor:t,onOpen:o,onClose:r,animate:n=!0,appendTo:p,popupOptions:u={},children:c,style:i})=>l.createElement(P.Popup,{show:e,anchor:t,style:i,animate:n,appendTo:p,onOpen:o,onClose:r,...u},c);exports.InlineAIPromptPopup=a;
|