@stack-spot/ai-chat-widget 1.13.2-beta.0 → 1.14.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -0
- package/dist/StackspotAIWidget.d.ts.map +1 -1
- package/dist/StackspotAIWidget.js +3 -2
- package/dist/StackspotAIWidget.js.map +1 -1
- package/dist/app-metadata.json +3 -3
- package/dist/chat-interceptors/CustomInputs.d.ts +2 -2
- package/dist/chat-interceptors/CustomInputs.d.ts.map +1 -1
- package/dist/chat-interceptors/CustomInputs.js.map +1 -1
- package/dist/chat-interceptors/quick-commands.js.map +1 -1
- package/dist/chat-interceptors/send-message.d.ts.map +1 -1
- package/dist/chat-interceptors/send-message.js +2 -0
- package/dist/chat-interceptors/send-message.js.map +1 -1
- package/dist/components/Markdown.d.ts.map +1 -1
- package/dist/components/Markdown.js +1 -1
- package/dist/components/Markdown.js.map +1 -1
- package/dist/components/StackedBadge.d.ts +14 -0
- package/dist/components/StackedBadge.d.ts.map +1 -0
- package/dist/components/StackedBadge.js +56 -0
- package/dist/components/StackedBadge.js.map +1 -0
- package/dist/components/ToolBadge.d.ts +14 -0
- package/dist/components/ToolBadge.d.ts.map +1 -0
- package/dist/components/ToolBadge.js +108 -0
- package/dist/components/ToolBadge.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/state/ChatEntry.d.ts +12 -19
- package/dist/state/ChatEntry.d.ts.map +1 -1
- package/dist/state/ChatEntry.js.map +1 -1
- package/dist/state/ChatState.d.ts +2 -5
- package/dist/state/ChatState.d.ts.map +1 -1
- package/dist/state/WidgetState.d.ts +3 -4
- package/dist/state/WidgetState.d.ts.map +1 -1
- package/dist/state/WidgetState.js +1 -12
- package/dist/state/WidgetState.js.map +1 -1
- package/dist/state/types.d.ts +3 -1
- package/dist/state/types.d.ts.map +1 -1
- package/dist/utils/tools.d.ts +7 -0
- package/dist/utils/tools.d.ts.map +1 -0
- package/dist/utils/tools.js +9 -0
- package/dist/utils/tools.js.map +1 -0
- package/dist/views/Agents/AgentDescription.d.ts.map +1 -1
- package/dist/views/Agents/AgentDescription.js +11 -1
- package/dist/views/Agents/AgentDescription.js.map +1 -1
- package/dist/views/Agents/AgentsTab.d.ts.map +1 -1
- package/dist/views/Agents/AgentsTab.js +4 -8
- package/dist/views/Agents/AgentsTab.js.map +1 -1
- package/dist/views/Agents/dictionary.d.ts +1 -1
- package/dist/views/Agents/dictionary.d.ts.map +1 -1
- package/dist/views/Agents/dictionary.js +2 -0
- package/dist/views/Agents/dictionary.js.map +1 -1
- package/dist/views/Agents/styled.js +1 -1
- package/dist/views/Chat/AgentInfo.d.ts +2 -2
- package/dist/views/Chat/AgentInfo.d.ts.map +1 -1
- package/dist/views/Chat/AgentInfo.js +3 -3
- package/dist/views/Chat/AgentInfo.js.map +1 -1
- package/dist/views/Chat/ChatMessage.d.ts.map +1 -1
- package/dist/views/Chat/ChatMessage.js +22 -4
- package/dist/views/Chat/ChatMessage.js.map +1 -1
- package/dist/views/Chat/StepsList.d.ts +2 -2
- package/dist/views/Chat/StepsList.d.ts.map +1 -1
- package/dist/views/Chat/StepsList.js +2 -2
- package/dist/views/Chat/StepsList.js.map +1 -1
- package/dist/views/Chat/styled.d.ts.map +1 -1
- package/dist/views/Chat/styled.js +21 -12
- package/dist/views/Chat/styled.js.map +1 -1
- package/dist/views/ChatHistory/utils.d.ts +2 -2
- package/dist/views/ChatHistory/utils.d.ts.map +1 -1
- package/dist/views/ChatTabSelection.d.ts.map +1 -1
- package/dist/views/ChatTabSelection.js +16 -2
- package/dist/views/ChatTabSelection.js.map +1 -1
- package/dist/views/MessageInput/AgentSelector.d.ts.map +1 -1
- package/dist/views/MessageInput/AgentSelector.js +5 -9
- package/dist/views/MessageInput/AgentSelector.js.map +1 -1
- package/dist/views/MessageInput/ButtonAgent.d.ts.map +1 -1
- package/dist/views/MessageInput/ButtonAgent.js +21 -2
- package/dist/views/MessageInput/ButtonAgent.js.map +1 -1
- package/dist/views/MessageInput/index.js +2 -2
- package/dist/views/MessageInput/index.js.map +1 -1
- package/dist/views/{Tools → Steps}/FlowChart/HandleGroup.d.ts.map +1 -1
- package/dist/views/{Tools → Steps}/FlowChart/HandleGroup.js.map +1 -1
- package/dist/views/{Tools → Steps}/FlowChart/NodeStep.d.ts.map +1 -1
- package/dist/views/Steps/FlowChart/NodeStep.js +13 -0
- package/dist/views/Steps/FlowChart/NodeStep.js.map +1 -0
- package/dist/views/Steps/FlowChart/index.d.ts +10 -0
- package/dist/views/Steps/FlowChart/index.d.ts.map +1 -0
- package/dist/views/{Tools → Steps}/FlowChart/index.js +1 -5
- package/dist/views/{Tools → Steps}/FlowChart/index.js.map +1 -1
- package/dist/views/{Tools → Steps}/FlowChart/layout.d.ts.map +1 -1
- package/dist/views/{Tools → Steps}/FlowChart/layout.js.map +1 -1
- package/dist/views/{Tools → Steps}/FlowChart/styled.d.ts.map +1 -1
- package/dist/views/{Tools → Steps}/FlowChart/styled.js +0 -49
- package/dist/views/{Tools → Steps}/FlowChart/styled.js.map +1 -1
- package/dist/views/{Tools → Steps}/FlowChart/types.d.ts +3 -3
- package/dist/views/Steps/FlowChart/types.d.ts.map +1 -0
- package/dist/views/Steps/FlowChart/types.js.map +1 -0
- package/dist/views/Steps/StepModal.d.ts +9 -0
- package/dist/views/Steps/StepModal.d.ts.map +1 -0
- package/dist/views/Steps/StepModal.js +124 -0
- package/dist/views/Steps/StepModal.js.map +1 -0
- package/dist/views/Steps/StepsPanel.d.ts +6 -0
- package/dist/views/Steps/StepsPanel.d.ts.map +1 -0
- package/dist/views/{Tools/ToolsPanel.js → Steps/StepsPanel.js} +3 -3
- package/dist/views/{Tools/ToolsPanel.js.map → Steps/StepsPanel.js.map} +1 -1
- package/dist/views/{Tools → Steps}/dictionary.d.ts +9 -11
- package/dist/views/Steps/dictionary.d.ts.map +1 -0
- package/dist/views/{Tools → Steps}/dictionary.js +9 -11
- package/dist/views/Steps/dictionary.js.map +1 -0
- package/dist/views/{Tools → Steps}/index.d.ts +1 -1
- package/dist/views/Steps/index.d.ts.map +1 -0
- package/dist/views/{Tools → Steps}/index.js +10 -10
- package/dist/views/{Tools → Steps}/index.js.map +1 -1
- package/dist/views/Steps/utils.d.ts +6 -0
- package/dist/views/Steps/utils.d.ts.map +1 -0
- package/dist/views/{Tools → Steps}/utils.js.map +1 -1
- package/dist/views/Tools.d.ts +2 -0
- package/dist/views/Tools.d.ts.map +1 -0
- package/dist/views/Tools.js +51 -0
- package/dist/views/Tools.js.map +1 -0
- package/package.json +2 -2
- package/src/StackspotAIWidget.tsx +2 -0
- package/src/app-metadata.json +3 -3
- package/src/chat-interceptors/CustomInputs.ts +3 -3
- package/src/chat-interceptors/quick-commands.ts +2 -2
- package/src/chat-interceptors/send-message.ts +4 -2
- package/src/components/Markdown.tsx +1 -0
- package/src/components/StackedBadge.tsx +77 -0
- package/src/components/ToolBadge.tsx +146 -0
- package/src/index.ts +1 -1
- package/src/state/ChatEntry.ts +12 -20
- package/src/state/ChatState.ts +2 -2
- package/src/state/WidgetState.ts +4 -16
- package/src/state/types.ts +4 -1
- package/src/utils/agent.ts +1 -1
- package/src/utils/tools.ts +11 -0
- package/src/views/Agents/AgentDescription.tsx +14 -0
- package/src/views/Agents/AgentsTab.tsx +5 -10
- package/src/views/Agents/dictionary.ts +2 -0
- package/src/views/Agents/styled.ts +1 -1
- package/src/views/Chat/AgentInfo.tsx +6 -6
- package/src/views/Chat/ChatMessage.tsx +34 -4
- package/src/views/Chat/StepsList.tsx +6 -6
- package/src/views/Chat/styled.ts +21 -12
- package/src/views/ChatHistory/utils.ts +2 -2
- package/src/views/ChatTabSelection.tsx +22 -4
- package/src/views/MessageInput/AgentSelector.tsx +7 -9
- package/src/views/MessageInput/ButtonAgent.tsx +26 -2
- package/src/views/MessageInput/index.tsx +2 -2
- package/src/views/{Tools → Steps}/FlowChart/NodeStep.tsx +11 -23
- package/src/views/{Tools → Steps}/FlowChart/index.tsx +3 -7
- package/src/views/{Tools → Steps}/FlowChart/styled.ts +0 -49
- package/src/views/{Tools → Steps}/FlowChart/types.ts +3 -3
- package/src/views/Steps/StepModal.tsx +216 -0
- package/src/views/{Tools/ToolsPanel.tsx → Steps/StepsPanel.tsx} +2 -2
- package/src/views/{Tools → Steps}/dictionary.ts +9 -11
- package/src/views/{Tools → Steps}/index.tsx +10 -10
- package/src/views/{Tools → Steps}/utils.tsx +4 -4
- package/src/views/Tools.tsx +71 -0
- package/dist/views/Tools/FlowChart/NodeStep.js +0 -15
- package/dist/views/Tools/FlowChart/NodeStep.js.map +0 -1
- package/dist/views/Tools/FlowChart/index.d.ts +0 -9
- package/dist/views/Tools/FlowChart/index.d.ts.map +0 -1
- package/dist/views/Tools/FlowChart/types.d.ts.map +0 -1
- package/dist/views/Tools/FlowChart/types.js.map +0 -1
- package/dist/views/Tools/StepModal.d.ts +0 -9
- package/dist/views/Tools/StepModal.d.ts.map +0 -1
- package/dist/views/Tools/StepModal.js +0 -156
- package/dist/views/Tools/StepModal.js.map +0 -1
- package/dist/views/Tools/ToolsPanel.d.ts +0 -6
- package/dist/views/Tools/ToolsPanel.d.ts.map +0 -1
- package/dist/views/Tools/dictionary.d.ts.map +0 -1
- package/dist/views/Tools/dictionary.js.map +0 -1
- package/dist/views/Tools/index.d.ts.map +0 -1
- package/dist/views/Tools/utils.d.ts +0 -6
- package/dist/views/Tools/utils.d.ts.map +0 -1
- package/src/views/Tools/StepModal.tsx +0 -247
- /package/dist/views/{Tools → Steps}/FlowChart/HandleGroup.d.ts +0 -0
- /package/dist/views/{Tools → Steps}/FlowChart/HandleGroup.js +0 -0
- /package/dist/views/{Tools → Steps}/FlowChart/NodeStep.d.ts +0 -0
- /package/dist/views/{Tools → Steps}/FlowChart/layout.d.ts +0 -0
- /package/dist/views/{Tools → Steps}/FlowChart/layout.js +0 -0
- /package/dist/views/{Tools → Steps}/FlowChart/styled.d.ts +0 -0
- /package/dist/views/{Tools → Steps}/FlowChart/types.js +0 -0
- /package/dist/views/{Tools → Steps}/utils.js +0 -0
- /package/src/views/{Tools → Steps}/FlowChart/HandleGroup.tsx +0 -0
- /package/src/views/{Tools → Steps}/FlowChart/layout.ts +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StepsPanel.d.ts","sourceRoot":"","sources":["../../../src/views/Steps/StepsPanel.tsx"],"names":[],"mappings":"AAOA,QAAA,MAAM,UAAU,GAAI,uBAAuB;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,mDAc/E,CAAA;AAED,eAAe,UAAU,CAAA"}
|
|
@@ -4,11 +4,11 @@ import { useMemo, useState } from 'react';
|
|
|
4
4
|
import { useWidget } from '../../context/hooks.js';
|
|
5
5
|
import { FlowChart } from './FlowChart/index.js';
|
|
6
6
|
import { StepModal } from './StepModal.js';
|
|
7
|
-
const
|
|
7
|
+
const StepsPanel = ({ chatId, messageId }) => {
|
|
8
8
|
const [currentStepId, setCurrentStepId] = useState();
|
|
9
9
|
const widget = useWidget();
|
|
10
10
|
const message = useMemo(() => widget.chatTabs.getAll().find(c => c.id === chatId)?.getMessages().find(m => m.id === messageId), [chatId, messageId]);
|
|
11
11
|
return message ? (_jsxs(_Fragment, { children: [_jsx(FlowChart, { message: message, onClick: (step) => setCurrentStepId(step.id) }), _jsx(StepModal, { message: message, stepId: currentStepId, onClose: () => setCurrentStepId(undefined) })] })) : null;
|
|
12
12
|
};
|
|
13
|
-
export default
|
|
14
|
-
//# sourceMappingURL=
|
|
13
|
+
export default StepsPanel;
|
|
14
|
+
//# sourceMappingURL=StepsPanel.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"
|
|
1
|
+
{"version":3,"file":"StepsPanel.js","sourceRoot":"","sources":["../../../src/views/Steps/StepsPanel.tsx"],"names":[],"mappings":";AAAA,6CAA6C;AAE7C,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM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|
tools: string;
|
|
@@ -10,15 +11,15 @@ export declare const dictionary: {
|
|
|
10
11
|
unknown: string;
|
|
11
12
|
running: string;
|
|
12
13
|
pending: string;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
thoughtFor: string;
|
|
14
|
+
nextAttempt: string;
|
|
15
|
+
previousAttempt: string;
|
|
16
16
|
open: string;
|
|
17
17
|
close: string;
|
|
18
18
|
input: string;
|
|
19
19
|
};
|
|
20
20
|
pt: {
|
|
21
|
-
|
|
21
|
+
stepsPanelDescription: string;
|
|
22
|
+
steps: string;
|
|
22
23
|
step: string;
|
|
23
24
|
response: string;
|
|
24
25
|
tools: string;
|
|
@@ -28,14 +29,11 @@ export declare const dictionary: {
|
|
|
28
29
|
unknown: string;
|
|
29
30
|
running: string;
|
|
30
31
|
pending: string;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
thoughtFor: string;
|
|
34
|
-
open: string;
|
|
35
|
-
close: string;
|
|
32
|
+
nextAttempt: string;
|
|
33
|
+
previousAttempt: string;
|
|
36
34
|
input: string;
|
|
37
35
|
};
|
|
38
36
|
};
|
|
39
|
-
export declare function
|
|
37
|
+
export declare function useStepsDictionary(): Record<"input" | "step" | "steps" | "tools" | "answer" | "pending" | "running" | "planning" | "unknown" | "stepsPanelDescription" | "response" | "executionTime" | "nextAttempt" | "previousAttempt", string>;
|
|
40
38
|
export type ToolsDictionary = typeof dictionary['en'];
|
|
41
39
|
//# sourceMappingURL=dictionary.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dictionary.d.ts","sourceRoot":"","sources":["../../../src/views/Steps/dictionary.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmCD,CAAA;AAEtB,wBAAgB,kBAAkB,kNAEjC;AAED,MAAM,MAAM,eAAe,GAAG,OAAO,UAAU,CAAC,IAAI,CAAC,CAAA"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { useTranslate } from '@stack-spot/portal-translate';
|
|
2
2
|
export const dictionary = {
|
|
3
3
|
en: {
|
|
4
|
-
|
|
4
|
+
stepsPanelDescription: 'The steps and tools used to reach the answer',
|
|
5
|
+
steps: 'Steps',
|
|
5
6
|
step: 'Step',
|
|
6
7
|
response: 'Response',
|
|
7
8
|
tools: 'Tools',
|
|
@@ -11,15 +12,15 @@ export const dictionary = {
|
|
|
11
12
|
unknown: 'unknown',
|
|
12
13
|
running: 'Running',
|
|
13
14
|
pending: 'Pending',
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
thoughtFor: 'Thought for $0 seconds',
|
|
15
|
+
nextAttempt: 'Next execution',
|
|
16
|
+
previousAttempt: 'Previous execution',
|
|
17
17
|
open: 'Open',
|
|
18
18
|
close: 'Close',
|
|
19
19
|
input: 'Input',
|
|
20
20
|
},
|
|
21
21
|
pt: {
|
|
22
|
-
|
|
22
|
+
stepsPanelDescription: 'Os passos e ferramentas usados para chegar na resposta',
|
|
23
|
+
steps: 'Passos',
|
|
23
24
|
step: 'Passo',
|
|
24
25
|
response: 'Resposta',
|
|
25
26
|
tools: 'Ferramentas',
|
|
@@ -29,15 +30,12 @@ export const dictionary = {
|
|
|
29
30
|
unknown: 'desconhecido',
|
|
30
31
|
running: 'Executando',
|
|
31
32
|
pending: 'Aguardando',
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
thoughtFor: 'Pensado por $0 segundos',
|
|
35
|
-
open: 'Open',
|
|
36
|
-
close: 'Close',
|
|
33
|
+
nextAttempt: 'Próxima execução',
|
|
34
|
+
previousAttempt: 'Execução anterior',
|
|
37
35
|
input: 'Entrada',
|
|
38
36
|
},
|
|
39
37
|
};
|
|
40
|
-
export function
|
|
38
|
+
export function useStepsDictionary() {
|
|
41
39
|
return useTranslate(dictionary);
|
|
42
40
|
}
|
|
43
41
|
//# sourceMappingURL=dictionary.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dictionary.js","sourceRoot":"","sources":["../../../src/views/Steps/dictionary.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,YAAY,EAAE,MAAM,8BAA8B,CAAA;AAEvE,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,EAAE,EAAE;QACF,qBAAqB,EAAE,8CAA8C;QACrE,KAAK,EAAE,OAAO;QACd,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,UAAU;QACpB,KAAK,EAAE,OAAO;QACd,QAAQ,EAAE,UAAU;QACpB,MAAM,EAAE,cAAc;QACtB,aAAa,EAAE,MAAM;QACrB,OAAO,EAAE,SAAS;QAClB,OAAO,EAAE,SAAS;QAClB,OAAO,EAAE,SAAS;QAClB,WAAW,EAAE,gBAAgB;QAC7B,eAAe,EAAE,oBAAoB;QACrC,IAAI,EAAE,MAAM;QACZ,KAAK,EAAE,OAAO;QACd,KAAK,EAAE,OAAO;KACf;IACD,EAAE,EAAE;QACF,qBAAqB,EAAE,wDAAwD;QAC/E,KAAK,EAAE,QAAQ;QACf,IAAI,EAAE,OAAO;QACb,QAAQ,EAAE,UAAU;QACpB,KAAK,EAAE,aAAa;QACpB,QAAQ,EAAE,cAAc;QACxB,MAAM,EAAE,gBAAgB;QACxB,aAAa,EAAE,OAAO;QACtB,OAAO,EAAE,cAAc;QACvB,OAAO,EAAE,YAAY;QACrB,OAAO,EAAE,YAAY;QACrB,WAAW,EAAE,kBAAkB;QAC/B,eAAe,EAAE,mBAAmB;QACpC,KAAK,EAAE,SAAS;KACjB;CACmB,CAAA;AAEtB,MAAM,UAAU,kBAAkB;IAChC,OAAO,YAAY,CAAC,UAAU,CAAC,CAAA;AACjC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/views/Steps/index.tsx"],"names":[],"mappings":"AASA;;GAEG;AACH,eAAO,MAAM,KAAK,YAwBjB,CAAA"}
|
|
@@ -4,25 +4,25 @@ import { LoadingCircular } from '@citric/ui';
|
|
|
4
4
|
import { lazy, Suspense, useEffect } from 'react';
|
|
5
5
|
import { useWidget, useWidgetState } from '../../context/hooks.js';
|
|
6
6
|
import { useRightPanel } from '../../right-panel/hooks.js';
|
|
7
|
-
import {
|
|
8
|
-
const
|
|
7
|
+
import { useStepsDictionary } from './dictionary.js';
|
|
8
|
+
const LazyStepsPanel = lazy(() => import('./StepsPanel.js'));
|
|
9
9
|
/**
|
|
10
10
|
* Renders the Stack selection form in the Right Panel if this is the panel that is currently opened.
|
|
11
11
|
*/
|
|
12
|
-
export const
|
|
13
|
-
const t =
|
|
12
|
+
export const Steps = () => {
|
|
13
|
+
const t = useStepsDictionary();
|
|
14
14
|
const panel = useWidgetState('panel');
|
|
15
|
-
const message = useWidgetState('
|
|
15
|
+
const message = useWidgetState('currentMessageInPanel');
|
|
16
16
|
const { open } = useRightPanel();
|
|
17
17
|
const widget = useWidget();
|
|
18
18
|
useEffect(() => {
|
|
19
|
-
if (panel === '
|
|
20
|
-
open(_jsx(Suspense, { fallback: _jsx(Flex, { alignItems: "center", justifyContent: "center", flex: 1, children: _jsx(LoadingCircular, {}) }), children: _jsx(
|
|
21
|
-
title: t.
|
|
22
|
-
description: t.
|
|
19
|
+
if (panel === 'steps' && message)
|
|
20
|
+
open(_jsx(Suspense, { fallback: _jsx(Flex, { alignItems: "center", justifyContent: "center", flex: 1, children: _jsx(LoadingCircular, {}) }), children: _jsx(LazyStepsPanel, { chatId: message.chatId, messageId: message.messageId }, message.messageId) }), {
|
|
21
|
+
title: t.steps,
|
|
22
|
+
description: t.stepsPanelDescription,
|
|
23
23
|
onClose: () => {
|
|
24
24
|
widget.set('panel', undefined);
|
|
25
|
-
widget.set('
|
|
25
|
+
widget.set('currentMessageInPanel', undefined);
|
|
26
26
|
},
|
|
27
27
|
});
|
|
28
28
|
}, [panel, t, message]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/views/
|
|
1
|
+
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AAE,CAAC,CAAC,qBAAqB;gBACpC,OAAO,EAAE,GAAG,EAAE;oBACZ,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,SAAS,CAAC,CAAA;oBAC9B,MAAM,CAAC,GAAG,CAAC,uBAAuB,EAAE,SAAS,CAAC,CAAA;gBAChD,CAAC;aACF,CACF,CAAA;IACH,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC,CAAA;IAEvB,OAAO,IAAI,CAAA;AACb,CAAC,CAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ChatStep } from '@stack-spot/portal-network';
|
|
2
|
+
export declare function getStatusIcon(status: ChatStep['status']): import("react/jsx-runtime").JSX.Element | null;
|
|
3
|
+
export declare function getTypeIcon(type: ChatStep['type']): import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
export declare function getTitle(translation: Record<'planning' | 'step' | 'answer', string>, step: ChatStep | undefined, index: number): string;
|
|
5
|
+
export declare function toPrecision(n: number, precisionDigits?: number): number;
|
|
6
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/views/Steps/utils.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAA;AAErD,wBAAgB,aAAa,CAAC,MAAM,EAAE,QAAQ,CAAC,QAAQ,CAAC,kDAOvD;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,2CAKjD;AAED,wBAAgB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC,UAAU,GAAG,MAAM,GAAG,QAAQ,EAAE,MAAM,CAAC,EAAE,IAAI,EAAE,QAAQ,GAAG,SAAS,EAAE,KAAK,EAAE,MAAM,UAO9H;AAED,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,eAAe,SAAI,UAGzD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/views/
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/views/Steps/utils.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AACzF,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAG5C,MAAM,UAAU,aAAa,CAAC,MAA0B;IACtD,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,SAAS,CAAC,CAAC,OAAO,KAAC,OAAO,IAAC,SAAS,EAAC,aAAa,YAAC,KAAC,eAAe,KAAG,GAAU,CAAA;QACrF,KAAK,OAAO,CAAC,CAAC,OAAO,KAAC,OAAO,IAAC,SAAS,EAAC,YAAY,YAAC,KAAC,eAAe,KAAG,GAAU,CAAA;QAClF,KAAK,SAAS,CAAC,CAAC,OAAO,KAAC,eAAe,IAAC,WAAW,EAAC,SAAS,EAAC,IAAI,EAAC,IAAI,GAAG,CAAA;QAC1E,OAAO,CAAC,CAAC,OAAO,IAAI,CAAA;IACtB,CAAC;AACH,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,IAAsB;IAChD,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,UAAU,CAAC,CAAC,OAAO,KAAC,aAAa,KAAG,CAAA;QACzC,OAAO,CAAC,CAAC,OAAO,KAAC,QAAQ,KAAG,CAAA;IAC9B,CAAC;AACH,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,WAA2D,EAAE,IAA0B,EAAE,KAAa;IAC7H,IAAI,CAAC,IAAI;QAAE,OAAO,EAAE,CAAA;IACpB,QAAQ,IAAI,CAAC,IAAI,EAAE,CAAC;QAClB,KAAK,UAAU,CAAC,CAAC,OAAO,WAAW,CAAC,QAAQ,CAAA;QAC5C,KAAK,MAAM,CAAC,CAAC,OAAO,GAAG,WAAW,CAAC,IAAI,IAAI,KAAK,EAAE,CAAA;QAClD,KAAK,QAAQ,CAAC,CAAC,OAAO,WAAW,CAAC,MAAM,CAAA;IAC1C,CAAC;AACH,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,CAAS,EAAE,eAAe,GAAG,CAAC;IACxD,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,eAAe,CAAC,CAAA;IAC5C,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,MAAM,CAAC,GAAG,MAAM,CAAA;AACxC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Tools.d.ts","sourceRoot":"","sources":["../../src/views/Tools.tsx"],"names":[],"mappings":"AAkBA,eAAO,MAAM,KAAK,YAejB,CAAA"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { agentClient } from '@stack-spot/portal-network';
|
|
3
|
+
import { useTranslate } from '@stack-spot/portal-translate';
|
|
4
|
+
import { useEffect, useMemo } from 'react';
|
|
5
|
+
import styled from 'styled-components';
|
|
6
|
+
import { ToolBadge } from '../components/ToolBadge.js';
|
|
7
|
+
import { useWidget, useWidgetState } from '../context/hooks.js';
|
|
8
|
+
import { useRightPanel } from '../right-panel/hooks.js';
|
|
9
|
+
import { toolById } from '../utils/tools.js';
|
|
10
|
+
const ToolList = styled.ul `
|
|
11
|
+
margin: 0;
|
|
12
|
+
padding: 0;
|
|
13
|
+
list-style: none;
|
|
14
|
+
display: flex;
|
|
15
|
+
flex-direction: column;
|
|
16
|
+
gap: 8px;
|
|
17
|
+
`;
|
|
18
|
+
export const Tools = () => {
|
|
19
|
+
const t = useTranslate(dictionary);
|
|
20
|
+
const panel = useWidgetState('panel');
|
|
21
|
+
const message = useWidgetState('currentMessageInPanel');
|
|
22
|
+
const { open } = useRightPanel();
|
|
23
|
+
const widget = useWidget();
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
if (panel === 'tools' && message)
|
|
26
|
+
open(_jsx(ToolsPanel, {}, message.messageId), { title: t.title, description: t.description, onClose: () => widget.set('panel', undefined) });
|
|
27
|
+
}, [panel, t]);
|
|
28
|
+
return null;
|
|
29
|
+
};
|
|
30
|
+
const ToolsPanel = () => {
|
|
31
|
+
const { chatId, messageId } = useWidgetState('currentMessageInPanel') ?? {};
|
|
32
|
+
const widget = useWidget();
|
|
33
|
+
const message = useMemo(() => {
|
|
34
|
+
const chat = widget.chatTabs.getAll().find(c => c.id === chatId);
|
|
35
|
+
return chat?.getMessages().find(m => m.id === messageId)?.getValue();
|
|
36
|
+
}, [messageId]);
|
|
37
|
+
const [agent] = agentClient.agent.useStatefulQuery({ agentId: message?.agent?.id ?? '' }, { enabled: !!message?.agent?.id });
|
|
38
|
+
const tools = useMemo(() => message?.tools?.map(id => toolById(id, agent?.toolkits) ?? { id }), [messageId, agent]);
|
|
39
|
+
return !!tools?.length && (_jsx(ToolList, { children: tools.map((tool) => (_jsx("li", { children: _jsx(ToolBadge, { name: tool.name || tool.id, image: tool.image, description: tool.description, backgroundColor: "light.500" }) }, tool.id))) }));
|
|
40
|
+
};
|
|
41
|
+
const dictionary = {
|
|
42
|
+
en: {
|
|
43
|
+
title: 'Tools',
|
|
44
|
+
description: 'The tools used to generate the answer.',
|
|
45
|
+
},
|
|
46
|
+
pt: {
|
|
47
|
+
title: 'Ferramentas',
|
|
48
|
+
description: 'As ferramentas usadas para gerar a resposta.',
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
//# sourceMappingURL=Tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Tools.js","sourceRoot":"","sources":["../../src/views/Tools.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AACxD,OAAO,EAAc,YAAY,EAAE,MAAM,8BAA8B,CAAA;AACvE,OAAO,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,CACN,CAAC,GACO,CACZ,CAAA;AACH,CAAC,CAAA;AAED,MAAM,UAAU,GAAG;IACjB,EAAE,EAAE;QACF,KAAK,EAAE,OAAO;QACd,WAAW,EAAE,wCAAwC;KACtD;IACD,EAAE,EAAE;QACF,KAAK,EAAE,aAAa;QACpB,WAAW,EAAE,8CAA8C;KAC5D;CACmB,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stack-spot/ai-chat-widget",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.14.0-beta.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"@citric/icons": "^5.9.0",
|
|
15
15
|
"@citric/ui": "^6.7.0",
|
|
16
16
|
"@stack-spot/portal-components": "^2.8.1",
|
|
17
|
-
"@stack-spot/portal-network": "^0.
|
|
17
|
+
"@stack-spot/portal-network": "^0.113.2",
|
|
18
18
|
"@stack-spot/portal-theme": "^1.0.0",
|
|
19
19
|
"@stack-spot/portal-translate": "^1.1.0",
|
|
20
20
|
"lodash": "^4.17.0",
|
|
@@ -17,6 +17,7 @@ import { KSDocument } from './views/KSDocument'
|
|
|
17
17
|
import { MessageInput } from './views/MessageInput'
|
|
18
18
|
import { MinimizedHeader } from './views/MinimizedHeader'
|
|
19
19
|
import { Stacks } from './views/Stacks'
|
|
20
|
+
import { Steps } from './views/Steps'
|
|
20
21
|
import { Tools } from './views/Tools'
|
|
21
22
|
import { Workspaces } from './views/Workspaces'
|
|
22
23
|
|
|
@@ -82,6 +83,7 @@ export const StackspotAIWidget = ({ username, minimizedActions = {}, prefix, chi
|
|
|
82
83
|
<Agents />
|
|
83
84
|
<Editor />
|
|
84
85
|
<ChatHistory />
|
|
86
|
+
<Steps />
|
|
85
87
|
<Tools />
|
|
86
88
|
<div className="chat-right-panel" ref={rightPanelRef}><RightPanel /></div>
|
|
87
89
|
</div>
|
package/src/app-metadata.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stack-spot/ai-chat-widget",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"date": "
|
|
3
|
+
"version": "1.14.0-beta.2",
|
|
4
|
+
"date": "Thu Apr 03 2025 10:36:32 GMT-0300 (Brasilia Standard Time)",
|
|
5
5
|
"dependencies": [
|
|
6
6
|
{
|
|
7
7
|
"name": "@stack-spot/app-metadata",
|
|
@@ -113,7 +113,7 @@
|
|
|
113
113
|
},
|
|
114
114
|
{
|
|
115
115
|
"name": "@stack-spot/portal-network",
|
|
116
|
-
"version": "0.
|
|
116
|
+
"version": "0.113.2(@stack-spot/auth@5.3.3)(@stack-spot/opa@2.6.1(@stack-spot/auth@5.3.3)(react-dom@18.2.0(react@18.2.0))(react@18.2.0))(@stack-spot/portal-translate@1.1.0(react-dom@18.2.0(react@18.2.0))(react@18.2.0))(@tanstack/react-query@5.69.0(react@18.2.0))(react-dom@18.2.0(react@18.2.0))(react@18.2.0)"
|
|
117
117
|
},
|
|
118
118
|
{
|
|
119
119
|
"name": "@stack-spot/portal-theme",
|
|
@@ -2,7 +2,7 @@ import { CustomInputResponse } from '@stack-spot/portal-network/api/ai'
|
|
|
2
2
|
import { Dictionary, translate } from '@stack-spot/portal-translate'
|
|
3
3
|
import { ChatEntry } from '../state/ChatEntry'
|
|
4
4
|
import { ChatState } from '../state/ChatState'
|
|
5
|
-
import {
|
|
5
|
+
import { LabeledAgent } from '../state/types'
|
|
6
6
|
|
|
7
7
|
const CUSTOM_INPUTS_KEY = 'customInputs'
|
|
8
8
|
|
|
@@ -12,9 +12,9 @@ export class CustomInputs {
|
|
|
12
12
|
private index = 0
|
|
13
13
|
private resolve?: (value: Record<string, string>) => void
|
|
14
14
|
private promise: Promise<Record<string, string>>
|
|
15
|
-
private agent?:
|
|
15
|
+
private agent?: LabeledAgent
|
|
16
16
|
|
|
17
|
-
constructor(inputs: CustomInputResponse[], agent?:
|
|
17
|
+
constructor(inputs: CustomInputResponse[], agent?: LabeledAgent) {
|
|
18
18
|
this.inputs = inputs
|
|
19
19
|
this.agent = agent
|
|
20
20
|
this.promise = new Promise(resolve => {
|
|
@@ -7,7 +7,7 @@ import { AbortedError } from '../AbortedError'
|
|
|
7
7
|
import { quickCommandRegex } from '../regex'
|
|
8
8
|
import { ChatEntry } from '../state/ChatEntry'
|
|
9
9
|
import { ChatState } from '../state/ChatState'
|
|
10
|
-
import {
|
|
10
|
+
import { LabeledAgent } from '../state/types'
|
|
11
11
|
import { WidgetState } from '../state/WidgetState'
|
|
12
12
|
import { buildConversationContext } from '../utils/chat'
|
|
13
13
|
import { getSizeOfString } from '../utils/string'
|
|
@@ -110,7 +110,7 @@ export function createQuickCommandInterceptor(widget: WidgetState, getEditor: ()
|
|
|
110
110
|
})
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
-
function createProgressMessage(agent?:
|
|
113
|
+
function createProgressMessage(agent?: LabeledAgent) {
|
|
114
114
|
return new ChatEntry({
|
|
115
115
|
agentType: 'bot',
|
|
116
116
|
content: '',
|
|
@@ -2,7 +2,7 @@ import { aiClient, ChatResponseWithSteps, StackspotAPIError, StreamCanceledError
|
|
|
2
2
|
import { ChatResponse3 } from '@stack-spot/portal-network/api/ai'
|
|
3
3
|
import { ChatEntry, KnowledgeSource, TextChatEntry } from '../state/ChatEntry'
|
|
4
4
|
import { ChatState } from '../state/ChatState'
|
|
5
|
-
import {
|
|
5
|
+
import { LabeledAgent } from '../state/types'
|
|
6
6
|
import { buildConversationContext } from '../utils/chat'
|
|
7
7
|
import { treatHTMLInErrorMessage } from '../utils/error'
|
|
8
8
|
import { genericSourcesToKnowledgeSources } from '../utils/knowledge-source'
|
|
@@ -12,13 +12,14 @@ import { genericSourcesToKnowledgeSources } from '../utils/knowledge-source'
|
|
|
12
12
|
* @param response the original response.
|
|
13
13
|
* @param knowledgeSources the knowledge sources already in format used by the chat.
|
|
14
14
|
* @param agent the current chat agent.
|
|
15
|
+
* @param tools the tools for the current chat agent.
|
|
15
16
|
* @param includeDate whether or not to include the date in the chat entry.
|
|
16
17
|
* @returns the TextChatEntry to build a ChatEntry.
|
|
17
18
|
*/
|
|
18
19
|
function createEntryValueFromChatResponse(
|
|
19
20
|
response: Partial<ChatResponseWithSteps>,
|
|
20
21
|
knowledgeSources: KnowledgeSource[] | undefined,
|
|
21
|
-
agent:
|
|
22
|
+
agent: LabeledAgent | undefined,
|
|
22
23
|
includeDate = false,
|
|
23
24
|
): TextChatEntry {
|
|
24
25
|
return {
|
|
@@ -30,6 +31,7 @@ function createEntryValueFromChatResponse(
|
|
|
30
31
|
agent: agent,
|
|
31
32
|
updated: includeDate ? new Date().toISOString() : undefined,
|
|
32
33
|
steps: response.steps,
|
|
34
|
+
tools: response.tools,
|
|
33
35
|
}
|
|
34
36
|
}
|
|
35
37
|
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { IconBox, Text } from '@citric/core'
|
|
2
|
+
import { theme } from '@stack-spot/portal-theme'
|
|
3
|
+
import { DetailedHTMLProps, HTMLAttributes } from 'react'
|
|
4
|
+
import { styled } from 'styled-components'
|
|
5
|
+
import { FastOmit } from 'styled-components/dist/types'
|
|
6
|
+
|
|
7
|
+
interface Props extends FastOmit<DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never> {
|
|
8
|
+
label: string,
|
|
9
|
+
images: { key?: React.Key, name: string, url?: string, icon?: React.ReactElement }[],
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const Styled = styled.div`
|
|
13
|
+
border-radius: 25px;
|
|
14
|
+
background-color: ${theme.color.light[600]};
|
|
15
|
+
border: 1px solid ${theme.color.light[500]};
|
|
16
|
+
color: ${theme.color.light[700]};
|
|
17
|
+
padding: 2px 7px;
|
|
18
|
+
display: flex;
|
|
19
|
+
gap: 5px;
|
|
20
|
+
align-items: center;
|
|
21
|
+
|
|
22
|
+
small {
|
|
23
|
+
line-height: 0.75rem;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
ul {
|
|
27
|
+
list-style: none;
|
|
28
|
+
margin: 0;
|
|
29
|
+
padding: 0;
|
|
30
|
+
display: flex;
|
|
31
|
+
flex-direction: row;
|
|
32
|
+
|
|
33
|
+
li {
|
|
34
|
+
border: 1px solid ${theme.color.light[600]};
|
|
35
|
+
background-color: ${theme.color.light[400]};
|
|
36
|
+
border-radius: 50%;
|
|
37
|
+
width: 16px;
|
|
38
|
+
height: 16px;
|
|
39
|
+
overflow: hidden;
|
|
40
|
+
display: flex;
|
|
41
|
+
align-items: center;
|
|
42
|
+
justify-content: center;
|
|
43
|
+
|
|
44
|
+
&:not(:first-child) {
|
|
45
|
+
margin-left: -12px;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
i {
|
|
50
|
+
width: 12px;
|
|
51
|
+
height: 12px;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
img, svg {
|
|
55
|
+
width: 100%;
|
|
56
|
+
height: 100%;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
`
|
|
60
|
+
|
|
61
|
+
export const StackedBadge = ({ label, images, ...props }: Props) => (
|
|
62
|
+
<Styled {...props}>
|
|
63
|
+
<Text appearance="microtext1">{label}</Text>
|
|
64
|
+
<ul>
|
|
65
|
+
{images.map(
|
|
66
|
+
({ key, name, url, icon }, i) => (
|
|
67
|
+
<li key={key || i}>
|
|
68
|
+
{url
|
|
69
|
+
? <img alt={name} aria-label={name} title={name} src={url} />
|
|
70
|
+
: <IconBox size="xs" aria-label={name} title={name}>{icon}</IconBox>
|
|
71
|
+
}
|
|
72
|
+
</li>
|
|
73
|
+
),
|
|
74
|
+
)}
|
|
75
|
+
</ul>
|
|
76
|
+
</Styled>
|
|
77
|
+
)
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { IconBox, Text } from '@citric/core'
|
|
2
|
+
import { ChevronDown, Cog } from '@citric/icons'
|
|
3
|
+
import { IconButton } from '@citric/ui'
|
|
4
|
+
import { AnimatedHeight } from '@stack-spot/portal-components/AnimatedHeight'
|
|
5
|
+
import { ColorSchemeKey, listToClass, theme } from '@stack-spot/portal-theme'
|
|
6
|
+
import { Dictionary, useTranslate } from '@stack-spot/portal-translate'
|
|
7
|
+
import { get } from 'lodash'
|
|
8
|
+
import { DetailedHTMLProps, HTMLAttributes, useState } from 'react'
|
|
9
|
+
import { styled } from 'styled-components'
|
|
10
|
+
import { FastOmit } from 'styled-components/dist/types'
|
|
11
|
+
import { toPrecision } from '../views/Steps/utils'
|
|
12
|
+
|
|
13
|
+
interface Props extends FastOmit<DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never> {
|
|
14
|
+
name: string,
|
|
15
|
+
duration?: number,
|
|
16
|
+
image?: string,
|
|
17
|
+
description?: string,
|
|
18
|
+
appearance?: 'round' | 'square',
|
|
19
|
+
backgroundColor?: ColorSchemeKey,
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const Styled = styled.div<{ $backgroundColor: ColorSchemeKey }>`
|
|
23
|
+
.tool-header-wrapper {
|
|
24
|
+
background-color: ${({ $backgroundColor }) => get(theme.color, $backgroundColor)};
|
|
25
|
+
border-radius: 8px;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.tool-header {
|
|
29
|
+
padding: 4px 8px 4px 4px;
|
|
30
|
+
display: flex;
|
|
31
|
+
flex-direction: column;
|
|
32
|
+
gap: 12px;
|
|
33
|
+
position: relative;
|
|
34
|
+
|
|
35
|
+
.title {
|
|
36
|
+
display: flex;
|
|
37
|
+
gap: 8px;
|
|
38
|
+
align-items: center;
|
|
39
|
+
.tool-image {
|
|
40
|
+
width: 24px;
|
|
41
|
+
height: 24px;
|
|
42
|
+
border-radius: 50%;
|
|
43
|
+
overflow: hidden;
|
|
44
|
+
flex-shrink: 0;
|
|
45
|
+
}
|
|
46
|
+
.name {
|
|
47
|
+
flex: 1;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.btn-expand {
|
|
52
|
+
display: none;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.duration {
|
|
56
|
+
opacity: 0.7;
|
|
57
|
+
text-align: right;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
&.with-description {
|
|
62
|
+
.tool-header {
|
|
63
|
+
&:before {
|
|
64
|
+
content: '';
|
|
65
|
+
top: 32px;
|
|
66
|
+
bottom: 8px;
|
|
67
|
+
left: 15px;
|
|
68
|
+
width: 1px;
|
|
69
|
+
background-color: ${theme.color.light[700]};
|
|
70
|
+
opacity: 0.3;
|
|
71
|
+
position: absolute;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.btn-expand {
|
|
75
|
+
display: flex;
|
|
76
|
+
transition: transform 0.3s ease-in-out;
|
|
77
|
+
&.open {
|
|
78
|
+
transform: rotate(180deg);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.description {
|
|
83
|
+
padding: 0 0 10px 20px;
|
|
84
|
+
opacity: 0.7;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
&.round {
|
|
90
|
+
.tool-header-wrapper {
|
|
91
|
+
border-radius: 30px;
|
|
92
|
+
}
|
|
93
|
+
&:not(.with-description) {
|
|
94
|
+
.tool-header-wrapper {
|
|
95
|
+
padding-right: 10px;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
`
|
|
100
|
+
|
|
101
|
+
export const ToolBadge = (
|
|
102
|
+
{ name, duration, image, description, appearance = 'square', backgroundColor = 'light.300', className, ...props }: Props,
|
|
103
|
+
) => {
|
|
104
|
+
const t = useTranslate(dictionary)
|
|
105
|
+
const [showDescription, setShowDescription] = useState(false)
|
|
106
|
+
const rootClass = listToClass([className, appearance, description && 'with-description'])
|
|
107
|
+
const wrapperClass = 'tool-header-wrapper'
|
|
108
|
+
|
|
109
|
+
const content = (
|
|
110
|
+
<div className="tool-header">
|
|
111
|
+
<div className="title">
|
|
112
|
+
{image ? <img src={image} className="tool-image" /> : <IconBox className="tool-image"><Cog /></IconBox>}
|
|
113
|
+
<Text colorScheme="light.700" className="name">{name}</Text>
|
|
114
|
+
{duration !== undefined && <Text colorScheme="light.700" className="duration">
|
|
115
|
+
{toPrecision(duration)}s
|
|
116
|
+
</Text>}
|
|
117
|
+
<IconButton
|
|
118
|
+
size="xs"
|
|
119
|
+
className={listToClass(['btn-expand', showDescription && 'open'])}
|
|
120
|
+
onClick={() => setShowDescription(v => !v)}
|
|
121
|
+
aria-label={showDescription ? t.close : t.open}
|
|
122
|
+
>
|
|
123
|
+
<ChevronDown />
|
|
124
|
+
</IconButton>
|
|
125
|
+
</div>
|
|
126
|
+
{showDescription && <Text className="description" colorScheme="light.700">{description}</Text>}
|
|
127
|
+
</div>
|
|
128
|
+
)
|
|
129
|
+
|
|
130
|
+
return (
|
|
131
|
+
<Styled {...props} $backgroundColor={backgroundColor} className={rootClass}>
|
|
132
|
+
{description ? <AnimatedHeight className={wrapperClass}>{content}</AnimatedHeight> : <div className={wrapperClass}>{content}</div>}
|
|
133
|
+
</Styled>
|
|
134
|
+
)
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const dictionary = {
|
|
138
|
+
en: {
|
|
139
|
+
open: 'Open',
|
|
140
|
+
close: 'Close',
|
|
141
|
+
},
|
|
142
|
+
pt: {
|
|
143
|
+
open: 'Abrir',
|
|
144
|
+
close: 'Fechar',
|
|
145
|
+
},
|
|
146
|
+
} satisfies Dictionary
|