@gooddata/sdk-ui-gen-ai 10.13.0-alpha.14 → 10.13.0-alpha.15
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/esm/components/EmptyState.d.ts +3 -3
- package/esm/components/EmptyState.d.ts.map +1 -1
- package/esm/components/EmptyState.js +10 -8
- package/esm/components/EmptyState.js.map +1 -1
- package/esm/components/ErrorBoundary.d.ts +10 -3
- package/esm/components/ErrorBoundary.d.ts.map +1 -1
- package/esm/components/ErrorBoundary.js +25 -7
- package/esm/components/ErrorBoundary.js.map +1 -1
- package/esm/components/GenAIChatOverlay.d.ts +3 -3
- package/esm/components/GenAIChatOverlay.d.ts.map +1 -1
- package/esm/components/GenAIChatOverlay.js +4 -4
- package/esm/components/GenAIChatOverlay.js.map +1 -1
- package/esm/components/GenAIChatWrapper.d.ts +7 -5
- package/esm/components/GenAIChatWrapper.d.ts.map +1 -1
- package/esm/components/GenAIChatWrapper.js +14 -1
- package/esm/components/GenAIChatWrapper.js.map +1 -1
- package/esm/components/GlobalError.d.ts +5 -15
- package/esm/components/GlobalError.d.ts.map +1 -1
- package/esm/components/GlobalError.js +5 -14
- package/esm/components/GlobalError.js.map +1 -1
- package/esm/components/Input.d.ts +4 -2
- package/esm/components/Input.d.ts.map +1 -1
- package/esm/components/Input.js +19 -10
- package/esm/components/Input.js.map +1 -1
- package/esm/components/Messages.d.ts +3 -3
- package/esm/components/Messages.d.ts.map +1 -1
- package/esm/components/Messages.js +21 -33
- package/esm/components/Messages.js.map +1 -1
- package/esm/components/messages/AgentIcon.d.ts.map +1 -1
- package/esm/components/messages/AgentIcon.js +10 -4
- package/esm/components/messages/AgentIcon.js.map +1 -1
- package/esm/components/messages/AssistantMessage.d.ts +8 -0
- package/esm/components/messages/AssistantMessage.d.ts.map +1 -0
- package/esm/components/messages/AssistantMessage.js +14 -0
- package/esm/components/messages/AssistantMessage.js.map +1 -0
- package/esm/components/messages/MessageContents.d.ts +10 -0
- package/esm/components/messages/MessageContents.d.ts.map +1 -0
- package/esm/components/messages/MessageContents.js +37 -0
- package/esm/components/messages/MessageContents.js.map +1 -0
- package/esm/components/messages/UserMessage.d.ts +8 -0
- package/esm/components/messages/UserMessage.d.ts.map +1 -0
- package/esm/components/messages/UserMessage.js +10 -0
- package/esm/components/messages/UserMessage.js.map +1 -0
- package/esm/components/messages/contents/ErrorContents.d.ts +7 -0
- package/esm/components/messages/contents/ErrorContents.d.ts.map +1 -0
- package/esm/components/messages/contents/ErrorContents.js +9 -0
- package/esm/components/messages/contents/ErrorContents.js.map +1 -0
- package/esm/components/messages/contents/RoutingContents.d.ts +7 -0
- package/esm/components/messages/contents/RoutingContents.d.ts.map +1 -0
- package/esm/components/messages/contents/RoutingContents.js +9 -0
- package/esm/components/messages/contents/RoutingContents.js.map +1 -0
- package/esm/components/messages/contents/SearchContents.d.ts +7 -0
- package/esm/components/messages/contents/SearchContents.d.ts.map +1 -0
- package/esm/components/messages/contents/SearchContents.js +19 -0
- package/esm/components/messages/contents/SearchContents.js.map +1 -0
- package/esm/components/messages/contents/TextContents.d.ts +7 -0
- package/esm/components/messages/contents/TextContents.d.ts.map +1 -0
- package/esm/components/messages/contents/TextContents.js +9 -0
- package/esm/components/messages/contents/TextContents.js.map +1 -0
- package/esm/components/messages/contents/VisualizationContents.d.ts +7 -0
- package/esm/components/messages/contents/VisualizationContents.d.ts.map +1 -0
- package/esm/components/messages/contents/VisualizationContents.js +54 -0
- package/esm/components/messages/contents/VisualizationContents.js.map +1 -0
- package/esm/components/messages/contents/VisualizationErrorBoundary.d.ts +16 -0
- package/esm/components/messages/contents/VisualizationErrorBoundary.d.ts.map +1 -0
- package/esm/components/messages/contents/VisualizationErrorBoundary.js +20 -0
- package/esm/components/messages/contents/VisualizationErrorBoundary.js.map +1 -0
- package/esm/components/messages/contents/parseText.d.ts +16 -0
- package/esm/components/messages/contents/parseText.d.ts.map +1 -0
- package/esm/components/messages/contents/parseText.js +54 -0
- package/esm/components/messages/contents/parseText.js.map +1 -0
- package/esm/components/messages/contents/useExecution.d.ts +6 -0
- package/esm/components/messages/contents/useExecution.d.ts.map +1 -0
- package/esm/components/messages/{useExecution.js → contents/useExecution.js} +9 -4
- package/esm/components/messages/contents/useExecution.js.map +1 -0
- package/esm/components/messages/index.d.ts +2 -4
- package/esm/components/messages/index.d.ts.map +1 -1
- package/esm/components/messages/index.js +2 -4
- package/esm/components/messages/index.js.map +1 -1
- package/esm/hooks/useGenAIStore.d.ts +8 -10
- package/esm/hooks/useGenAIStore.d.ts.map +1 -1
- package/esm/index.d.ts +1 -1
- package/esm/index.d.ts.map +1 -1
- package/esm/localization/bundles/en-US.json +9 -9
- package/esm/model.d.ts +70 -53
- package/esm/model.d.ts.map +1 -1
- package/esm/model.js +46 -43
- package/esm/model.js.map +1 -1
- package/esm/sdk-ui-gen-ai.d.ts +59 -46
- package/esm/store/index.d.ts +2 -4
- package/esm/store/index.d.ts.map +1 -1
- package/esm/store/index.js +2 -4
- package/esm/store/index.js.map +1 -1
- package/esm/store/messages/messagesSelectors.d.ts +5 -3
- package/esm/store/messages/messagesSelectors.d.ts.map +1 -1
- package/esm/store/messages/messagesSelectors.js +5 -12
- package/esm/store/messages/messagesSelectors.js.map +1 -1
- package/esm/store/messages/messagesSlice.d.ts +51 -4
- package/esm/store/messages/messagesSlice.d.ts.map +1 -1
- package/esm/store/messages/messagesSlice.js +122 -23
- package/esm/store/messages/messagesSlice.js.map +1 -1
- package/esm/store/sideEffects/converters/interactionsToMessages.d.ts +9 -0
- package/esm/store/sideEffects/converters/interactionsToMessages.d.ts.map +1 -0
- package/esm/store/sideEffects/converters/interactionsToMessages.js +36 -0
- package/esm/store/sideEffects/converters/interactionsToMessages.js.map +1 -0
- package/esm/store/sideEffects/index.d.ts.map +1 -1
- package/esm/store/sideEffects/index.js +8 -5
- package/esm/store/sideEffects/index.js.map +1 -1
- package/esm/store/sideEffects/onThreadClear.d.ts +18 -0
- package/esm/store/sideEffects/onThreadClear.d.ts.map +1 -0
- package/esm/store/sideEffects/onThreadClear.js +31 -0
- package/esm/store/sideEffects/onThreadClear.js.map +1 -0
- package/esm/store/sideEffects/onThreadLoad.d.ts +20 -0
- package/esm/store/sideEffects/onThreadLoad.d.ts.map +1 -0
- package/esm/store/sideEffects/onThreadLoad.js +41 -0
- package/esm/store/sideEffects/onThreadLoad.js.map +1 -0
- package/esm/store/sideEffects/onUserMessage.d.ts +37 -0
- package/esm/store/sideEffects/onUserMessage.d.ts.map +1 -0
- package/esm/store/sideEffects/onUserMessage.js +65 -0
- package/esm/store/sideEffects/onUserMessage.js.map +1 -0
- package/esm/store/store.d.ts +8 -10
- package/esm/store/store.d.ts.map +1 -1
- package/esm/store/store.js +2 -4
- package/esm/store/store.js.map +1 -1
- package/esm/store/types.d.ts +0 -2
- package/esm/store/types.d.ts.map +1 -1
- package/esm/store/types.js +0 -1
- package/esm/store/types.js.map +1 -1
- package/package.json +14 -12
- package/styles/css/main.css +44 -39
- package/styles/css/main.css.map +1 -1
- package/styles/css/messages.css +54 -27
- package/styles/css/messages.css.map +1 -1
- package/styles/scss/main.scss +0 -1
- package/styles/scss/messages.scss +124 -98
- package/esm/components/messages/AgentState.d.ts +0 -3
- package/esm/components/messages/AgentState.d.ts.map +0 -1
- package/esm/components/messages/AgentState.js +0 -12
- package/esm/components/messages/AgentState.js.map +0 -1
- package/esm/components/messages/AssistantCancelledMessage.d.ts +0 -8
- package/esm/components/messages/AssistantCancelledMessage.d.ts.map +0 -1
- package/esm/components/messages/AssistantCancelledMessage.js +0 -12
- package/esm/components/messages/AssistantCancelledMessage.js.map +0 -1
- package/esm/components/messages/AssistantErrorMessage.d.ts +0 -11
- package/esm/components/messages/AssistantErrorMessage.d.ts.map +0 -1
- package/esm/components/messages/AssistantErrorMessage.js +0 -14
- package/esm/components/messages/AssistantErrorMessage.js.map +0 -1
- package/esm/components/messages/AssistantSearchCreateMessage.d.ts +0 -8
- package/esm/components/messages/AssistantSearchCreateMessage.d.ts.map +0 -1
- package/esm/components/messages/AssistantSearchCreateMessage.js +0 -16
- package/esm/components/messages/AssistantSearchCreateMessage.js.map +0 -1
- package/esm/components/messages/AssistantTextMessage.d.ts +0 -8
- package/esm/components/messages/AssistantTextMessage.d.ts.map +0 -1
- package/esm/components/messages/AssistantTextMessage.js +0 -10
- package/esm/components/messages/AssistantTextMessage.js.map +0 -1
- package/esm/components/messages/FoundObjects.d.ts +0 -8
- package/esm/components/messages/FoundObjects.d.ts.map +0 -1
- package/esm/components/messages/FoundObjects.js +0 -28
- package/esm/components/messages/FoundObjects.js.map +0 -1
- package/esm/components/messages/SystemMessage.d.ts +0 -8
- package/esm/components/messages/SystemMessage.d.ts.map +0 -1
- package/esm/components/messages/SystemMessage.js +0 -7
- package/esm/components/messages/SystemMessage.js.map +0 -1
- package/esm/components/messages/UserTextMessage.d.ts +0 -8
- package/esm/components/messages/UserTextMessage.d.ts.map +0 -1
- package/esm/components/messages/UserTextMessage.js +0 -10
- package/esm/components/messages/UserTextMessage.js.map +0 -1
- package/esm/components/messages/Visualization.d.ts +0 -8
- package/esm/components/messages/Visualization.d.ts.map +0 -1
- package/esm/components/messages/Visualization.js +0 -39
- package/esm/components/messages/Visualization.js.map +0 -1
- package/esm/components/messages/useExecution.d.ts +0 -6
- package/esm/components/messages/useExecution.d.ts.map +0 -1
- package/esm/components/messages/useExecution.js.map +0 -1
- package/esm/store/agent/agentSelectors.d.ts +0 -3
- package/esm/store/agent/agentSelectors.d.ts.map +0 -1
- package/esm/store/agent/agentSelectors.js +0 -6
- package/esm/store/agent/agentSelectors.js.map +0 -1
- package/esm/store/agent/agentSlice.d.ts +0 -8
- package/esm/store/agent/agentSlice.d.ts.map +0 -1
- package/esm/store/agent/agentSlice.js +0 -21
- package/esm/store/agent/agentSlice.js.map +0 -1
- package/esm/store/sideEffects/converters/evalToMessage.d.ts +0 -7
- package/esm/store/sideEffects/converters/evalToMessage.d.ts.map +0 -1
- package/esm/store/sideEffects/converters/evalToMessage.js +0 -14
- package/esm/store/sideEffects/converters/evalToMessage.js.map +0 -1
- package/esm/store/sideEffects/converters/messagesToHistory.d.ts +0 -4
- package/esm/store/sideEffects/converters/messagesToHistory.d.ts.map +0 -1
- package/esm/store/sideEffects/converters/messagesToHistory.js +0 -83
- package/esm/store/sideEffects/converters/messagesToHistory.js.map +0 -1
- package/esm/store/sideEffects/onNewMessage.d.ts +0 -13
- package/esm/store/sideEffects/onNewMessage.d.ts.map +0 -1
- package/esm/store/sideEffects/onNewMessage.js +0 -81
- package/esm/store/sideEffects/onNewMessage.js.map +0 -1
- package/styles/css/agentState.css +0 -29
- package/styles/css/agentState.css.map +0 -1
- package/styles/scss/agentState.scss +0 -31
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { setMessagesAction } from "../store/index.js";
|
|
3
3
|
import { WrappedComponentProps } from "react-intl";
|
|
4
4
|
type EmptyStateDispatchProps = {
|
|
5
|
-
|
|
5
|
+
setMessagesAction: typeof setMessagesAction;
|
|
6
6
|
};
|
|
7
7
|
export declare const EmptyState: import("react-redux").ConnectedComponent<React.FC<import("react-intl").WithIntlProps<EmptyStateDispatchProps & WrappedComponentProps>> & {
|
|
8
8
|
WrappedComponent: React.ComponentType<EmptyStateDispatchProps & WrappedComponentProps>;
|
|
9
9
|
}, import("react-redux").Omit<Omit<EmptyStateDispatchProps & WrappedComponentProps, "intl"> & {
|
|
10
10
|
forwardedRef?: React.Ref<any> | undefined;
|
|
11
|
-
}, "
|
|
11
|
+
}, "setMessagesAction">>;
|
|
12
12
|
export {};
|
|
13
13
|
//# sourceMappingURL=EmptyState.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EmptyState.d.ts","sourceRoot":"","sources":["../../src/components/EmptyState.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"EmptyState.d.ts","sourceRoot":"","sources":["../../src/components/EmptyState.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAA+C,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAuBhG,KAAK,uBAAuB,GAAG;IAC3B,iBAAiB,EAAE,OAAO,iBAAiB,CAAC;CAC/C,CAAC;AA0CF,eAAO,MAAM,UAAU;;;;wBAAqE,CAAC"}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { Button, Icon, Typography } from "@gooddata/sdk-ui-kit";
|
|
4
4
|
import { connect } from "react-redux";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { makeAssistantMessage, makeTextContents, makeUserMessage } from "../model.js";
|
|
6
|
+
import { setMessagesAction } from "../store/index.js";
|
|
7
7
|
import { defineMessage, FormattedMessage, injectIntl } from "react-intl";
|
|
8
8
|
const quickOptions = [
|
|
9
9
|
{
|
|
@@ -25,21 +25,23 @@ const quickOptions = [
|
|
|
25
25
|
Icon: Icon.ChatBubble,
|
|
26
26
|
},
|
|
27
27
|
];
|
|
28
|
-
const EmptyStateComponent = ({
|
|
28
|
+
const EmptyStateComponent = ({ setMessagesAction, intl, }) => {
|
|
29
29
|
return (React.createElement("div", { className: "gd-gen-ai-chat__messages__empty" },
|
|
30
30
|
React.createElement(Typography, { tagName: "h1", className: "gd-gen-ai-chat__messages__empty__h1--accent" },
|
|
31
31
|
React.createElement(FormattedMessage, { id: "gd.gen-ai.welcome.line-1" })),
|
|
32
32
|
React.createElement(Typography, { tagName: "h1" },
|
|
33
33
|
React.createElement(FormattedMessage, { id: "gd.gen-ai.welcome.line-2" })),
|
|
34
|
-
quickOptions.map((option) => (React.createElement(Button, { key: option.title.id, onClick: () =>
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
quickOptions.map((option) => (React.createElement(Button, { key: option.title.id, onClick: () => setMessagesAction({
|
|
35
|
+
messages: [
|
|
36
|
+
makeUserMessage([makeTextContents(intl.formatMessage(option.question))]),
|
|
37
|
+
makeAssistantMessage([makeTextContents(intl.formatMessage(option.answer))], true),
|
|
38
|
+
],
|
|
39
|
+
}), variant: "secondary" },
|
|
38
40
|
React.createElement(option.Icon, { width: 18, height: 18 }),
|
|
39
41
|
React.createElement(FormattedMessage, { tagName: "span", id: option.title.id }))))));
|
|
40
42
|
};
|
|
41
43
|
const mapDispatchToProps = {
|
|
42
|
-
|
|
44
|
+
setMessagesAction,
|
|
43
45
|
};
|
|
44
46
|
export const EmptyState = connect(null, mapDispatchToProps)(injectIntl(EmptyStateComponent));
|
|
45
47
|
//# sourceMappingURL=EmptyState.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EmptyState.js","sourceRoot":"","sources":["../../src/components/EmptyState.tsx"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"EmptyState.js","sourceRoot":"","sources":["../../src/components/EmptyState.tsx"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACtF,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,UAAU,EAAyB,MAAM,YAAY,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AC,MAAM,IACH,GAAG,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,EACpB,OAAO,EAAE,GAAG,EAAE,CACV,iBAAiB,CAAC;gBACd,QAAQ,EAAE;oBACN,eAAe,CAAC,CAAC,gBAAgB,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;oBACxE,oBAAoB,CAChB,CAAC,gBAAgB,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EACrD,IAAI,CACP;iBACJ;aACJ,CAAC,EAEN,OAAO,EAAC,WAAW;YAEnB,oBAAC,MAAM,CAAC,IAAI,IAAC,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,GAAI;YACtC,oBAAC,gBAAgB,IAAC,OAAO,EAAC,MAAM,EAAC,EAAE,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,GAAI,CACnD,CACZ,CAAC,CACA,CACT,CAAC;AACN,CAAC,CAAC;AAEF,MAAM,kBAAkB,GAA4B;IAChD,iBAAiB;CACpB,CAAC;AAEF,MAAM,CAAC,MAAM,UAAU,GAAG,OAAO,CAAC,IAAI,EAAE,kBAAkB,CAAC,CAAC,UAAU,CAAC,mBAAmB,CAAC,CAAC,CAAC"}
|
|
@@ -1,16 +1,23 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
import { setGlobalErrorAction } from "../store/index.js";
|
|
2
3
|
type ErrorBoundaryProps = {
|
|
3
4
|
children: React.ReactNode;
|
|
5
|
+
globalError?: string;
|
|
6
|
+
setGlobalError: typeof setGlobalErrorAction;
|
|
7
|
+
clearThread: () => void;
|
|
4
8
|
};
|
|
5
9
|
type ErrorBoundaryState = {
|
|
6
|
-
|
|
10
|
+
ownError?: string;
|
|
7
11
|
};
|
|
8
|
-
|
|
12
|
+
declare class ErrorBoundaryComponent extends React.Component<ErrorBoundaryProps, ErrorBoundaryState> {
|
|
9
13
|
constructor(props: ErrorBoundaryProps);
|
|
10
14
|
static getDerivedStateFromError(error: unknown): {
|
|
11
|
-
|
|
15
|
+
ownError: string;
|
|
12
16
|
};
|
|
17
|
+
componentDidCatch(error: Error, _errorInfo: React.ErrorInfo): void;
|
|
18
|
+
clearError(): void;
|
|
13
19
|
render(): string | number | boolean | Iterable<React.ReactNode> | React.JSX.Element | null | undefined;
|
|
14
20
|
}
|
|
21
|
+
export declare const ErrorBoundary: import("react-redux").ConnectedComponent<typeof ErrorBoundaryComponent, import("react-redux").Omit<React.ClassAttributes<ErrorBoundaryComponent> & ErrorBoundaryProps, "globalError" | "setGlobalError" | "clearThread">>;
|
|
15
22
|
export {};
|
|
16
23
|
//# sourceMappingURL=ErrorBoundary.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ErrorBoundary.d.ts","sourceRoot":"","sources":["../../src/components/ErrorBoundary.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,KAAK,kBAAkB,GAAG;IACtB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"ErrorBoundary.d.ts","sourceRoot":"","sources":["../../src/components/ErrorBoundary.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,OAAO,EAAkC,oBAAoB,EAAqB,MAAM,mBAAmB,CAAC;AAE5G,KAAK,kBAAkB,GAAG;IACtB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,OAAO,oBAAoB,CAAC;IAC5C,WAAW,EAAE,MAAM,IAAI,CAAC;CAC3B,CAAC;AAEF,KAAK,kBAAkB,GAAG;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,cAAM,sBAAuB,SAAQ,KAAK,CAAC,SAAS,CAAC,kBAAkB,EAAE,kBAAkB,CAAC;gBAC5E,KAAK,EAAE,kBAAkB;IAKrC,MAAM,CAAC,wBAAwB,CAAC,KAAK,EAAE,OAAO;;;IAI9C,iBAAiB,CAAC,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,CAAC,SAAS;IAI3D,UAAU;IAKV,MAAM;CAUT;AAWD,eAAO,MAAM,aAAa,2NAAuE,CAAC"}
|
|
@@ -1,22 +1,40 @@
|
|
|
1
1
|
// (C) 2024 GoodData Corporation
|
|
2
2
|
import React from "react";
|
|
3
|
+
import { connect } from "react-redux";
|
|
3
4
|
import { GlobalError } from "./GlobalError.js";
|
|
4
5
|
import { extractError } from "../store/sideEffects/utils.js";
|
|
5
|
-
|
|
6
|
+
import { globalErrorSelector, setGlobalErrorAction, clearThreadAction } from "../store/index.js";
|
|
7
|
+
class ErrorBoundaryComponent extends React.Component {
|
|
6
8
|
constructor(props) {
|
|
7
9
|
super(props);
|
|
8
|
-
this.state = {
|
|
10
|
+
this.state = { ownError: "" };
|
|
9
11
|
}
|
|
10
12
|
static getDerivedStateFromError(error) {
|
|
11
|
-
return {
|
|
13
|
+
return { ownError: extractError(error) };
|
|
14
|
+
}
|
|
15
|
+
componentDidCatch(error, _errorInfo) {
|
|
16
|
+
this.props.setGlobalError({ error: extractError(error) });
|
|
17
|
+
}
|
|
18
|
+
clearError() {
|
|
19
|
+
this.props.clearThread();
|
|
20
|
+
this.setState({ ownError: "" });
|
|
12
21
|
}
|
|
13
22
|
render() {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
23
|
+
// Catch both global error from store or local React error
|
|
24
|
+
// And treat them the same
|
|
25
|
+
const error = this.props.globalError || this.state.ownError;
|
|
26
|
+
if (error) {
|
|
27
|
+
return React.createElement(GlobalError, { errorDetails: error, clearError: this.clearError.bind(this) });
|
|
18
28
|
}
|
|
19
29
|
return this.props.children;
|
|
20
30
|
}
|
|
21
31
|
}
|
|
32
|
+
const mapStateToProps = (state) => ({
|
|
33
|
+
globalError: globalErrorSelector(state),
|
|
34
|
+
});
|
|
35
|
+
const mapDispatchToProps = {
|
|
36
|
+
setGlobalError: setGlobalErrorAction,
|
|
37
|
+
clearThread: clearThreadAction,
|
|
38
|
+
};
|
|
39
|
+
export const ErrorBoundary = connect(mapStateToProps, mapDispatchToProps)(ErrorBoundaryComponent);
|
|
22
40
|
//# sourceMappingURL=ErrorBoundary.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ErrorBoundary.js","sourceRoot":"","sources":["../../src/components/ErrorBoundary.tsx"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"ErrorBoundary.js","sourceRoot":"","sources":["../../src/components/ErrorBoundary.tsx"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EAAa,mBAAmB,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAa5G,MAAM,sBAAuB,SAAQ,KAAK,CAAC,SAAiD;IACxF,YAAY,KAAyB;QACjC,KAAK,CAAC,KAAK,CAAC,CAAC;QACb,IAAI,CAAC,KAAK,GAAG,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC;IAClC,CAAC;IAED,MAAM,CAAC,wBAAwB,CAAC,KAAc;QAC1C,OAAO,EAAE,QAAQ,EAAE,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC;IAC7C,CAAC;IAED,iBAAiB,CAAC,KAAY,EAAE,UAA2B;QACvD,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,EAAE,KAAK,EAAE,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAC9D,CAAC;IAED,UAAU;QACN,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC;QACzB,IAAI,CAAC,QAAQ,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CAAC;IACpC,CAAC;IAED,MAAM;QACF,0DAA0D;QAC1D,0BAA0B;QAC1B,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC;QAC5D,IAAI,KAAK,EAAE,CAAC;YACR,OAAO,oBAAC,WAAW,IAAC,YAAY,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,GAAI,CAAC;QACxF,CAAC;QAED,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC;IAC/B,CAAC;CACJ;AAED,MAAM,eAAe,GAAG,CAAC,KAAgB,EAAE,EAAE,CAAC,CAAC;IAC3C,WAAW,EAAE,mBAAmB,CAAC,KAAK,CAAC;CAC1C,CAAC,CAAC;AAEH,MAAM,kBAAkB,GAAG;IACvB,cAAc,EAAE,oBAAoB;IACpC,WAAW,EAAE,iBAAiB;CACjC,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAAG,OAAO,CAAC,eAAe,EAAE,kBAAkB,CAAC,CAAC,sBAAsB,CAAC,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { clearThreadAction } from "../store/index.js";
|
|
3
3
|
import { WrappedComponentProps } from "react-intl";
|
|
4
4
|
type GenAIChatOverlayOwnProps = {
|
|
5
5
|
onClose: () => void;
|
|
@@ -8,13 +8,13 @@ type GenAIChatOverlayStateProps = {
|
|
|
8
8
|
hasMessages: boolean;
|
|
9
9
|
};
|
|
10
10
|
type GenAIChatOverlayDispatchProps = {
|
|
11
|
-
|
|
11
|
+
clearThread: typeof clearThreadAction;
|
|
12
12
|
};
|
|
13
13
|
export type GenAIChatOverlayProps = GenAIChatOverlayOwnProps & GenAIChatOverlayStateProps & GenAIChatOverlayDispatchProps;
|
|
14
14
|
export declare const GenAIChatOverlay: import("react-redux").ConnectedComponent<React.FC<import("react-intl").WithIntlProps<GenAIChatOverlayOwnProps & GenAIChatOverlayStateProps & GenAIChatOverlayDispatchProps & WrappedComponentProps>> & {
|
|
15
15
|
WrappedComponent: React.ComponentType<GenAIChatOverlayOwnProps & GenAIChatOverlayStateProps & GenAIChatOverlayDispatchProps & WrappedComponentProps>;
|
|
16
16
|
}, import("react-redux").Omit<Omit<GenAIChatOverlayOwnProps & GenAIChatOverlayStateProps & GenAIChatOverlayDispatchProps & WrappedComponentProps, "intl"> & {
|
|
17
17
|
forwardedRef?: React.Ref<any> | undefined;
|
|
18
|
-
}, "
|
|
18
|
+
}, "clearThread" | "hasMessages">>;
|
|
19
19
|
export {};
|
|
20
20
|
//# sourceMappingURL=GenAIChatOverlay.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GenAIChatOverlay.d.ts","sourceRoot":"","sources":["../../src/components/GenAIChatOverlay.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"GenAIChatOverlay.d.ts","sourceRoot":"","sources":["../../src/components/GenAIChatOverlay.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,iBAAiB,EAAkC,MAAM,mBAAmB,CAAC;AAItF,OAAO,EAAc,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAE/D,KAAK,wBAAwB,GAAG;IAC5B,OAAO,EAAE,MAAM,IAAI,CAAC;CACvB,CAAC;AAEF,KAAK,0BAA0B,GAAG;IAC9B,WAAW,EAAE,OAAO,CAAC;CACxB,CAAC;AAEF,KAAK,6BAA6B,GAAG;IACjC,WAAW,EAAE,OAAO,iBAAiB,CAAC;CACzC,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG,wBAAwB,GACxD,0BAA0B,GAC1B,6BAA6B,CAAC;AAsElC,eAAO,MAAM,gBAAgB;;;;kCAGW,CAAC"}
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { GenAIChatWrapper } from "./GenAIChatWrapper.js";
|
|
4
4
|
import { Icon, Overlay } from "@gooddata/sdk-ui-kit";
|
|
5
|
-
import {
|
|
5
|
+
import { clearThreadAction, hasMessagesSelector } from "../store/index.js";
|
|
6
6
|
import cx from "classnames";
|
|
7
7
|
import { HeaderIcon } from "./HeaderIcon.js";
|
|
8
8
|
import { connect } from "react-redux";
|
|
9
9
|
import { injectIntl } from "react-intl";
|
|
10
|
-
const GenAIChatOverlayComponent = ({ onClose, hasMessages,
|
|
10
|
+
const GenAIChatOverlayComponent = ({ onClose, hasMessages, clearThread, intl, }) => {
|
|
11
11
|
const [isFullScreen, setIsFullScreen] = React.useState(false);
|
|
12
12
|
const isModal = isFullScreen;
|
|
13
13
|
const classNames = cx("gd-gen-ai-chat__window", {
|
|
@@ -16,7 +16,7 @@ const GenAIChatOverlayComponent = ({ onClose, hasMessages, clearMessages, intl,
|
|
|
16
16
|
return (React.createElement(Overlay, { isModal: isModal, positionType: "fixed", alignPoints: [{ align: isModal ? "cc cc" : "br br" }], closeOnEscape: true, closeOnParentScroll: false, closeOnOutsideClick: false, closeOnMouseDrag: false, zIndex: 6000, onClose: onClose },
|
|
17
17
|
React.createElement("div", { className: classNames },
|
|
18
18
|
React.createElement("div", { className: "gd-gen-ai-chat__window__header" },
|
|
19
|
-
React.createElement(HeaderIcon, { Icon: Icon.Undo, className: "gd-gen-ai-chat__window__header__icon--reset", tooltip: intl.formatMessage({ id: "gd.gen-ai.header.reset-tooltip" }), onClick: () =>
|
|
19
|
+
React.createElement(HeaderIcon, { Icon: Icon.Undo, className: "gd-gen-ai-chat__window__header__icon--reset", tooltip: intl.formatMessage({ id: "gd.gen-ai.header.reset-tooltip" }), onClick: () => clearThread(), disabled: !hasMessages }),
|
|
20
20
|
React.createElement("div", { className: "gd-gen-ai-chat__window__header__gap" }),
|
|
21
21
|
React.createElement(HeaderIcon, { Icon: isFullScreen ? Icon.Contract : Icon.Expand, className: "gd-gen-ai-chat__window__header__icon--fullscreen", tooltip: isFullScreen
|
|
22
22
|
? intl.formatMessage({ id: "gd.gen-ai.header.contract-tooltip" })
|
|
@@ -29,7 +29,7 @@ const mapStateToProps = (state) => ({
|
|
|
29
29
|
hasMessages: hasMessagesSelector(state),
|
|
30
30
|
});
|
|
31
31
|
const mapDispatchToProps = {
|
|
32
|
-
|
|
32
|
+
clearThread: clearThreadAction,
|
|
33
33
|
};
|
|
34
34
|
export const GenAIChatOverlay = connect(mapStateToProps, mapDispatchToProps)(injectIntl(GenAIChatOverlayComponent));
|
|
35
35
|
//# sourceMappingURL=GenAIChatOverlay.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GenAIChatOverlay.js","sourceRoot":"","sources":["../../src/components/GenAIChatOverlay.tsx"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"GenAIChatOverlay.js","sourceRoot":"","sources":["../../src/components/GenAIChatOverlay.tsx"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE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
|
|
4
|
+
loadThread: typeof loadThreadAction;
|
|
5
|
+
cancelLoading: typeof cancelAsyncAction;
|
|
6
|
+
};
|
|
7
|
+
export declare const GenAIChatWrapper: import("react-redux").ConnectedComponent<React.FC<GenAIChatWrapperProps>, import("react-redux").Omit<GenAIChatWrapperProps, "loadThread" | "cancelLoading">>;
|
|
8
|
+
export {};
|
|
7
9
|
//# sourceMappingURL=GenAIChatWrapper.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GenAIChatWrapper.d.ts","sourceRoot":"","sources":["../../src/components/GenAIChatWrapper.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAO1B
|
|
1
|
+
{"version":3,"file":"GenAIChatWrapper.d.ts","sourceRoot":"","sources":["../../src/components/GenAIChatWrapper.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAO1B,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAExE,KAAK,qBAAqB,GAAG;IACzB,UAAU,EAAE,OAAO,gBAAgB,CAAC;IACpC,aAAa,EAAE,OAAO,iBAAiB,CAAC;CAC3C,CAAC;AAiCF,eAAO,MAAM,gBAAgB,8JAA+D,CAAC"}
|
|
@@ -5,11 +5,19 @@ import { Messages } from "./Messages.js";
|
|
|
5
5
|
import { Typography } from "@gooddata/sdk-ui-kit";
|
|
6
6
|
import { ErrorBoundary } from "./ErrorBoundary.js";
|
|
7
7
|
import { FormattedMessage } from "react-intl";
|
|
8
|
+
import { connect } from "react-redux";
|
|
9
|
+
import { loadThreadAction, cancelAsyncAction } from "../store/index.js";
|
|
8
10
|
/**
|
|
9
11
|
* UI component that renders the Gen AI chat.
|
|
10
12
|
* @internal
|
|
11
13
|
*/
|
|
12
|
-
|
|
14
|
+
const GenAIChatWrapperComponent = ({ loadThread, cancelLoading }) => {
|
|
15
|
+
React.useEffect(() => {
|
|
16
|
+
loadThread();
|
|
17
|
+
return () => {
|
|
18
|
+
cancelLoading();
|
|
19
|
+
};
|
|
20
|
+
}, [loadThread, cancelLoading]);
|
|
13
21
|
return (React.createElement(ErrorBoundary, null,
|
|
14
22
|
React.createElement("div", { className: "gd-gen-ai-chat" },
|
|
15
23
|
React.createElement(Messages, null),
|
|
@@ -17,4 +25,9 @@ export const GenAIChatWrapper = () => {
|
|
|
17
25
|
React.createElement(Typography, { tagName: "p", className: "gd-gen-ai-chat__disclaimer" },
|
|
18
26
|
React.createElement(FormattedMessage, { id: "gd.gen-ai.disclaimer" })))));
|
|
19
27
|
};
|
|
28
|
+
const mapDispatchToProps = {
|
|
29
|
+
loadThread: loadThreadAction,
|
|
30
|
+
cancelLoading: cancelAsyncAction,
|
|
31
|
+
};
|
|
32
|
+
export const GenAIChatWrapper = connect(null, mapDispatchToProps)(GenAIChatWrapperComponent);
|
|
20
33
|
//# sourceMappingURL=GenAIChatWrapper.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GenAIChatWrapper.js","sourceRoot":"","sources":["../../src/components/GenAIChatWrapper.tsx"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"GenAIChatWrapper.js","sourceRoot":"","sources":["../../src/components/GenAIChatWrapper.tsx"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAOxE;;;GAGG;AACH,MAAM,yBAAyB,GAAoC,CAAC,EAAE,UAAU,EAAE,aAAa,EAAE,EAAE,EAAE;IACjG,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACjB,UAAU,EAAE,CAAC;QAEb,OAAO,GAAG,EAAE;YACR,aAAa,EAAE,CAAC;QACpB,CAAC,CAAC;IACN,CAAC,EAAE,CAAC,UAAU,EAAE,aAAa,CAAC,CAAC,CAAC;IAEhC,OAAO,CACH,oBAAC,aAAa;QACV,6BAAK,SAAS,EAAC,gBAAgB;YAC3B,oBAAC,QAAQ,OAAG;YACZ,oBAAC,KAAK,OAAG;YACT,oBAAC,UAAU,IAAC,OAAO,EAAC,GAAG,EAAC,SAAS,EAAC,4BAA4B;gBAC1D,oBAAC,gBAAgB,IAAC,EAAE,EAAC,sBAAsB,GAAG,CACrC,CACX,CACM,CACnB,CAAC;AACN,CAAC,CAAC;AAEF,MAAM,kBAAkB,GAAG;IACvB,UAAU,EAAE,gBAAgB;IAC5B,aAAa,EAAE,iBAAiB;CACnC,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAG,OAAO,CAAC,IAAI,EAAE,kBAAkB,CAAC,CAAC,yBAAyB,CAAC,CAAC"}
|
|
@@ -1,21 +1,11 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { WrappedComponentProps } from "react-intl";
|
|
3
|
-
type
|
|
4
|
-
clearMessagesAction: () => void;
|
|
5
|
-
};
|
|
6
|
-
export declare const GlobalError: import("react-redux").ConnectedComponent<React.FC<import("react-intl").WithIntlProps<GlobalErrorDispatchProps & {
|
|
7
|
-
errorDetails: string;
|
|
8
|
-
clearError: () => void;
|
|
9
|
-
} & WrappedComponentProps>> & {
|
|
10
|
-
WrappedComponent: React.ComponentType<GlobalErrorDispatchProps & {
|
|
11
|
-
errorDetails: string;
|
|
12
|
-
clearError: () => void;
|
|
13
|
-
} & WrappedComponentProps>;
|
|
14
|
-
}, import("react-redux").Omit<Omit<GlobalErrorDispatchProps & {
|
|
3
|
+
type GlobalErrorProps = {
|
|
15
4
|
errorDetails: string;
|
|
16
5
|
clearError: () => void;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
|
|
6
|
+
};
|
|
7
|
+
export declare const GlobalError: React.FC<import("react-intl").WithIntlProps<GlobalErrorProps & WrappedComponentProps>> & {
|
|
8
|
+
WrappedComponent: React.ComponentType<GlobalErrorProps & WrappedComponentProps>;
|
|
9
|
+
};
|
|
20
10
|
export {};
|
|
21
11
|
//# sourceMappingURL=GlobalError.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GlobalError.d.ts","sourceRoot":"","sources":["../../src/components/GlobalError.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"GlobalError.d.ts","sourceRoot":"","sources":["../../src/components/GlobalError.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAgC,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAEjF,KAAK,gBAAgB,GAAG;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,IAAI,CAAC;CAC1B,CAAC;AAoCF,eAAO,MAAM,WAAW;;CAAmC,CAAC"}
|
|
@@ -1,25 +1,16 @@
|
|
|
1
1
|
// (C) 2024 GoodData Corporation
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { Button, Typography } from "@gooddata/sdk-ui-kit";
|
|
4
|
-
import { connect } from "react-redux";
|
|
5
|
-
import { clearMessagesAction } from "../store/index.js";
|
|
6
4
|
import { FormattedMessage, injectIntl } from "react-intl";
|
|
7
|
-
const GlobalErrorComponent = ({ errorDetails,
|
|
5
|
+
const GlobalErrorComponent = ({ errorDetails, clearError, intl, }) => {
|
|
8
6
|
const [showMore, setShowMore] = React.useState(false);
|
|
9
|
-
const
|
|
10
|
-
const clearCallback = () => {
|
|
11
|
-
clearMessagesAction();
|
|
12
|
-
clearError();
|
|
13
|
-
};
|
|
7
|
+
const hasShowMoreButton = Boolean(errorDetails && !showMore);
|
|
14
8
|
return (React.createElement("div", { className: "gd-gen-ai-chat__global_error" },
|
|
15
9
|
React.createElement(Typography, { tagName: "p" },
|
|
16
10
|
React.createElement(FormattedMessage, { id: "gd.gen-ai.global-error" })),
|
|
17
|
-
React.createElement(Button, { className: "gd-button-link", value: intl.formatMessage({ id: "gd.gen-ai.global-error.button-clear" }), onClick:
|
|
18
|
-
|
|
11
|
+
React.createElement(Button, { className: "gd-button-link", value: intl.formatMessage({ id: "gd.gen-ai.global-error.button-clear" }), onClick: clearError }),
|
|
12
|
+
hasShowMoreButton ? (React.createElement(Button, { className: "gd-button-link", value: intl.formatMessage({ id: "gd.gen-ai.global-error.button-details" }), onClick: () => setShowMore(true) })) : null,
|
|
19
13
|
showMore ? (React.createElement(Typography, { tagName: "p", className: "gd-gen-ai-chat__global_error__details" }, errorDetails)) : null));
|
|
20
14
|
};
|
|
21
|
-
const
|
|
22
|
-
clearMessagesAction,
|
|
23
|
-
};
|
|
24
|
-
export const GlobalError = connect(null, mapDispatchToProps)(injectIntl(GlobalErrorComponent));
|
|
15
|
+
export const GlobalError = injectIntl(GlobalErrorComponent);
|
|
25
16
|
//# sourceMappingURL=GlobalError.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GlobalError.js","sourceRoot":"","sources":["../../src/components/GlobalError.tsx"],"names":[],"mappings":"AAAA,gCAAgC;AAEhC,OA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AAU,IAAC,OAAO,EAAC,GAAG,EAAC,SAAS,EAAC,uCAAuC,IACpE,YAAY,CACJ,CAChB,CAAC,CAAC,CAAC,IAAI,CACN,CACT,CAAC;AACN,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,WAAW,GAAG,UAAU,CAAC,oBAAoB,CAAC,CAAC"}
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { newMessageAction } from "../store/index.js";
|
|
2
|
+
import { newMessageAction, cancelLastInteractionAction } from "../store/index.js";
|
|
3
3
|
import { WrappedComponentProps } from "react-intl/src/components/injectIntl.js";
|
|
4
4
|
type InputStateProps = {
|
|
5
5
|
isBusy: boolean;
|
|
6
|
+
isEvaluating: boolean;
|
|
6
7
|
};
|
|
7
8
|
type InputDispatchProps = {
|
|
8
9
|
newMessage: typeof newMessageAction;
|
|
10
|
+
cancelMessage: typeof cancelLastInteractionAction;
|
|
9
11
|
};
|
|
10
12
|
export declare const Input: import("react-redux").ConnectedComponent<React.FC<import("react-intl").WithIntlProps<InputStateProps & InputDispatchProps & WrappedComponentProps>> & {
|
|
11
13
|
WrappedComponent: React.ComponentType<InputStateProps & InputDispatchProps & WrappedComponentProps>;
|
|
12
14
|
}, import("react-redux").Omit<Omit<InputStateProps & InputDispatchProps & WrappedComponentProps, "intl"> & {
|
|
13
15
|
forwardedRef?: React.Ref<any> | undefined;
|
|
14
|
-
}, "isBusy" | "newMessage">>;
|
|
16
|
+
}, "isBusy" | "isEvaluating" | "newMessage" | "cancelMessage">>;
|
|
15
17
|
export {};
|
|
16
18
|
//# sourceMappingURL=Input.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Input.d.ts","sourceRoot":"","sources":["../../src/components/Input.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAO1B,OAAO,
|
|
1
|
+
{"version":3,"file":"Input.d.ts","sourceRoot":"","sources":["../../src/components/Input.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAO1B,OAAO,EAEH,gBAAgB,EAChB,2BAA2B,EAE9B,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EAAE,qBAAqB,EAAE,MAAM,yCAAyC,CAAC;AAOhF,KAAK,eAAe,GAAG;IACnB,MAAM,EAAE,OAAO,CAAC;IAChB,YAAY,EAAE,OAAO,CAAC;CACzB,CAAC;AAEF,KAAK,kBAAkB,GAAG;IACtB,UAAU,EAAE,OAAO,gBAAgB,CAAC;IACpC,aAAa,EAAE,OAAO,2BAA2B,CAAC;CACrD,CAAC;AA6FF,eAAO,MAAM,KAAK;;;;+DAA2E,CAAC"}
|
package/esm/components/Input.js
CHANGED
|
@@ -5,15 +5,15 @@ import { defaultImport } from "default-import";
|
|
|
5
5
|
import cx from "classnames";
|
|
6
6
|
import { SendIcon } from "./SendIcon.js";
|
|
7
7
|
import { connect } from "react-redux";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
8
|
+
import { makeTextContents, makeUserMessage } from "../model.js";
|
|
9
|
+
import { asyncProcessSelector, newMessageAction, cancelLastInteractionAction, } from "../store/index.js";
|
|
10
10
|
import { StopIcon } from "./StopIcon.js";
|
|
11
11
|
import { injectIntl } from "react-intl";
|
|
12
12
|
// There are known compatibility issues between CommonJS (CJS) and ECMAScript modules (ESM).
|
|
13
13
|
// In ESM, default exports of CJS modules are wrapped in default properties instead of being exposed directly.
|
|
14
14
|
// https://github.com/microsoft/TypeScript/issues/52086#issuecomment-1385978414
|
|
15
15
|
const TextareaAutosize = defaultImport(DefaultTextArea);
|
|
16
|
-
const InputComponent = ({ isBusy, newMessage, intl, }) => {
|
|
16
|
+
const InputComponent = ({ isBusy, isEvaluating, newMessage, cancelMessage, intl, }) => {
|
|
17
17
|
const [value, setValue] = React.useState("");
|
|
18
18
|
const textareaRef = React.useRef(null);
|
|
19
19
|
React.useEffect(() => {
|
|
@@ -25,11 +25,11 @@ const InputComponent = ({ isBusy, newMessage, intl, }) => {
|
|
|
25
25
|
}
|
|
26
26
|
}, [isBusy]);
|
|
27
27
|
const handleSubmit = () => {
|
|
28
|
-
newMessage(
|
|
28
|
+
newMessage(makeUserMessage([makeTextContents(value)]));
|
|
29
29
|
setValue("");
|
|
30
30
|
};
|
|
31
31
|
const handleCancel = () => {
|
|
32
|
-
|
|
32
|
+
cancelMessage();
|
|
33
33
|
};
|
|
34
34
|
const handleKeyDown = (e) => {
|
|
35
35
|
if (e.key === "Enter" && !e.shiftKey && !isBusy && value) {
|
|
@@ -40,18 +40,27 @@ const InputComponent = ({ isBusy, newMessage, intl, }) => {
|
|
|
40
40
|
const handleChange = (e) => {
|
|
41
41
|
setValue(e.target.value);
|
|
42
42
|
};
|
|
43
|
+
const buttonDisabled = !value || isBusy;
|
|
43
44
|
const buttonClasses = cx("gd-gen-ai-chat__input__send_button", {
|
|
44
|
-
"gd-gen-ai-chat__input__send_button--disabled":
|
|
45
|
+
"gd-gen-ai-chat__input__send_button--disabled": buttonDisabled,
|
|
45
46
|
});
|
|
46
47
|
return (React.createElement("div", { className: "gd-gen-ai-chat__input" },
|
|
47
48
|
React.createElement(TextareaAutosize, { ref: textareaRef, className: "gd-gen-ai-chat__input__textarea", placeholder: intl.formatMessage({ id: "gd.gen-ai.input-placeholder" }), value: value, onChange: handleChange, onKeyDown: handleKeyDown, disabled: isBusy }),
|
|
48
|
-
React.createElement("div", {
|
|
49
|
+
!isEvaluating ? (React.createElement("div", { role: "button", "aria-label": intl.formatMessage({ id: "gd.gen-ai.button.send" }), onClick: !buttonDisabled ? handleSubmit : undefined },
|
|
50
|
+
React.createElement(SendIcon, { className: buttonClasses }))) : null,
|
|
51
|
+
isEvaluating ? (React.createElement("div", { role: "button", "aria-label": intl.formatMessage({ id: "gd.gen-ai.button.abort" }), onClick: handleCancel },
|
|
52
|
+
React.createElement(StopIcon, { className: "gd-gen-ai-chat__input__send_button" }))) : null));
|
|
53
|
+
};
|
|
54
|
+
const mapStateToProps = (state) => {
|
|
55
|
+
const asyncState = asyncProcessSelector(state);
|
|
56
|
+
return {
|
|
57
|
+
isBusy: !!asyncState,
|
|
58
|
+
isEvaluating: asyncState === "evaluating",
|
|
59
|
+
};
|
|
49
60
|
};
|
|
50
|
-
const mapStateToProps = (state) => ({
|
|
51
|
-
isBusy: agentLoadingSelector(state),
|
|
52
|
-
});
|
|
53
61
|
const mapDispatchToProps = {
|
|
54
62
|
newMessage: newMessageAction,
|
|
63
|
+
cancelMessage: cancelLastInteractionAction,
|
|
55
64
|
};
|
|
56
65
|
export const Input = connect(mapStateToProps, mapDispatchToProps)(injectIntl(InputComponent));
|
|
57
66
|
//# sourceMappingURL=Input.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Input.js","sourceRoot":"","sources":["../../src/components/Input.tsx"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,eAAe,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"Input.js","sourceRoot":"","sources":["../../src/components/Input.tsx"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,eAAe,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACh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ACN,CACT,CAAC;AACN,CAAC,CAAC;AAEF,MAAM,eAAe,GAAG,CAAC,KAAgB,EAAmB,EAAE;IAC1D,MAAM,UAAU,GAAG,oBAAoB,CAAC,KAAK,CAAC,CAAC;IAE/C,OAAO;QACH,MAAM,EAAE,CAAC,CAAC,UAAU;QACpB,YAAY,EAAE,UAAU,KAAK,YAAY;KAC5C,CAAC;AACN,CAAC,CAAC;AAEF,MAAM,kBAAkB,GAAG;IACvB,UAAU,EAAE,gBAAgB;IAC5B,aAAa,EAAE,2BAA2B;CAC7C,CAAC;AAEF,MAAM,CAAC,MAAM,KAAK,GAAG,OAAO,CAAC,eAAe,EAAE,kBAAkB,CAAC,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { asyncProcessSelector, messagesSelector } from "../store/index.js";
|
|
3
3
|
type MessagesComponentProps = {
|
|
4
|
-
messages: ReturnType<typeof
|
|
5
|
-
loading: ReturnType<typeof
|
|
4
|
+
messages: ReturnType<typeof messagesSelector>;
|
|
5
|
+
loading: ReturnType<typeof asyncProcessSelector>;
|
|
6
6
|
};
|
|
7
7
|
export declare const Messages: import("react-redux").ConnectedComponent<React.FC<MessagesComponentProps>, import("react-redux").Omit<MessagesComponentProps, "loading" | "messages">>;
|
|
8
8
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Messages.d.ts","sourceRoot":"","sources":["../../src/components/Messages.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,oBAAoB,EAAa,
|
|
1
|
+
{"version":3,"file":"Messages.d.ts","sourceRoot":"","sources":["../../src/components/Messages.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,oBAAoB,EAAa,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAMtF,KAAK,sBAAsB,GAAG;IAC1B,QAAQ,EAAE,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAC;IAC9C,OAAO,EAAE,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC;CACpD,CAAC;AA8CF,eAAO,MAAM,QAAQ,wJAA8C,CAAC"}
|
|
@@ -1,55 +1,43 @@
|
|
|
1
1
|
// (C) 2024 GoodData Corporation
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { connect } from "react-redux";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { AgentState } from "./messages/AgentState.js";
|
|
7
|
-
import { isAssistantErrorMessage, isAssistantSearchCreateMessage, isAssistantTextMessage, isAssistantCancelledMessage, isUserTextMessage, isSystemTextMessage, } from "../model.js";
|
|
4
|
+
import { asyncProcessSelector, messagesSelector } from "../store/index.js";
|
|
5
|
+
import { AssistantMessageComponent, UserMessageComponent } from "./messages/index.js";
|
|
8
6
|
import { EmptyState } from "./EmptyState.js";
|
|
9
|
-
import {
|
|
10
|
-
import
|
|
7
|
+
import { isAssistantMessage, isUserMessage } from "../model.js";
|
|
8
|
+
import Skeleton from "react-loading-skeleton";
|
|
11
9
|
const MessagesComponent = ({ messages, loading }) => {
|
|
12
10
|
const scrollRef = React.useRef(null);
|
|
13
11
|
const lastMessage = messages[messages.length - 1];
|
|
14
12
|
React.useLayoutEffect(() => {
|
|
15
|
-
//
|
|
13
|
+
// Last message will also change when it's loading state is updated
|
|
16
14
|
scrollRef.current?.scrollTo({
|
|
17
15
|
top: scrollRef.current?.scrollHeight,
|
|
18
16
|
behavior: "smooth",
|
|
19
17
|
});
|
|
20
|
-
}, [lastMessage
|
|
18
|
+
}, [lastMessage]);
|
|
21
19
|
return (React.createElement("div", { className: "gd-gen-ai-chat__messages", ref: scrollRef },
|
|
22
20
|
React.createElement("div", { className: "gd-gen-ai-chat__messages__scroll" },
|
|
23
|
-
!messages.length ? React.createElement(EmptyState, null) : null,
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
if (isAssistantCancelledMessage(message)) {
|
|
38
|
-
return React.createElement(AssistantCancelledMessageComponent, { key: message.id, message: message });
|
|
39
|
-
}
|
|
40
|
-
if (isSystemTextMessage(message)) {
|
|
41
|
-
return React.createElement(SystemMessageComponent, { key: message.id, message: message });
|
|
42
|
-
}
|
|
43
|
-
return assertNever(message);
|
|
44
|
-
}),
|
|
45
|
-
loading ? React.createElement(AgentState, null) : null)));
|
|
21
|
+
!messages.length && !loading ? React.createElement(EmptyState, null) : null,
|
|
22
|
+
loading === "loading" || loading === "clearing" ? React.createElement(Skeleton, { count: 3, height: "2em" }) : null,
|
|
23
|
+
loading !== "loading" && loading !== "clearing"
|
|
24
|
+
? messages.map((message) => {
|
|
25
|
+
if (isUserMessage(message)) {
|
|
26
|
+
return React.createElement(UserMessageComponent, { key: message.localId, message: message });
|
|
27
|
+
}
|
|
28
|
+
if (isAssistantMessage(message)) {
|
|
29
|
+
return React.createElement(AssistantMessageComponent, { key: message.localId, message: message });
|
|
30
|
+
}
|
|
31
|
+
return assertNever(message);
|
|
32
|
+
})
|
|
33
|
+
: null)));
|
|
46
34
|
};
|
|
47
35
|
const assertNever = (value) => {
|
|
48
36
|
throw new Error(`Unhandled message role: ${value}`);
|
|
49
37
|
};
|
|
50
38
|
const mapStateToProps = (state) => ({
|
|
51
|
-
messages:
|
|
52
|
-
loading:
|
|
39
|
+
messages: messagesSelector(state),
|
|
40
|
+
loading: asyncProcessSelector(state),
|
|
53
41
|
});
|
|
54
42
|
export const Messages = connect(mapStateToProps)(MessagesComponent);
|
|
55
43
|
//# sourceMappingURL=Messages.js.map
|