@uipath/ui-widgets-conversational-agent-chat 1.0.2 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +63 -6
- package/dist/ConversationalAgentChat.css +18184 -7
- package/dist/ConversationalAgentChat.d.ts +1 -1
- package/dist/ConversationalAgentChat.d.ts.map +1 -1
- package/dist/ConversationalAgentChat.js +617 -139
- package/dist/ConversationalAgentChat.js.map +1 -1
- package/dist/ConversationalAgentChat.stories.d.ts +14 -1
- package/dist/ConversationalAgentChat.stories.d.ts.map +1 -1
- package/dist/ConversationalAgentChat.stories.js +5 -12
- package/dist/ConversationalAgentChat.stories.js.map +1 -1
- package/dist/ConversationalAgentPickerChat.d.ts +4 -0
- package/dist/ConversationalAgentPickerChat.d.ts.map +1 -0
- package/dist/ConversationalAgentPickerChat.js +113 -0
- package/dist/ConversationalAgentPickerChat.js.map +1 -0
- package/dist/ConversationalAgentPickerChat.stories.d.ts +96 -0
- package/dist/ConversationalAgentPickerChat.stories.d.ts.map +1 -0
- package/dist/ConversationalAgentPickerChat.stories.js +209 -0
- package/dist/ConversationalAgentPickerChat.stories.js.map +1 -0
- package/dist/components/AgentList.d.ts +10 -0
- package/dist/components/AgentList.d.ts.map +1 -0
- package/dist/components/AgentList.js +20 -0
- package/dist/components/AgentList.js.map +1 -0
- package/dist/components/AgentSchemaForm/AgentSchemaField.d.ts +26 -0
- package/dist/components/AgentSchemaForm/AgentSchemaField.d.ts.map +1 -0
- package/dist/components/AgentSchemaForm/AgentSchemaField.js +96 -0
- package/dist/components/AgentSchemaForm/AgentSchemaField.js.map +1 -0
- package/dist/components/AgentSchemaForm/AgentSchemaForm.d.ts +38 -0
- package/dist/components/AgentSchemaForm/AgentSchemaForm.d.ts.map +1 -0
- package/dist/components/AgentSchemaForm/AgentSchemaForm.js +105 -0
- package/dist/components/AgentSchemaForm/AgentSchemaForm.js.map +1 -0
- package/dist/components/AgentSchemaForm/AgentSchemaForm.stories.d.ts +30 -0
- package/dist/components/AgentSchemaForm/AgentSchemaForm.stories.d.ts.map +1 -0
- package/dist/components/AgentSchemaForm/AgentSchemaForm.stories.js +236 -0
- package/dist/components/AgentSchemaForm/AgentSchemaForm.stories.js.map +1 -0
- package/dist/components/AgentSchemaForm/FieldShell.d.ts +12 -0
- package/dist/components/AgentSchemaForm/FieldShell.d.ts.map +1 -0
- package/dist/components/AgentSchemaForm/FieldShell.js +4 -0
- package/dist/components/AgentSchemaForm/FieldShell.js.map +1 -0
- package/dist/components/AgentSchemaForm/index.d.ts +5 -0
- package/dist/components/AgentSchemaForm/index.d.ts.map +1 -0
- package/dist/components/AgentSchemaForm/index.js +2 -0
- package/dist/components/AgentSchemaForm/index.js.map +1 -0
- package/dist/components/AgentSchemaForm/inputs/ArrayField.d.ts +7 -0
- package/dist/components/AgentSchemaForm/inputs/ArrayField.d.ts.map +1 -0
- package/dist/components/AgentSchemaForm/inputs/ArrayField.js +28 -0
- package/dist/components/AgentSchemaForm/inputs/ArrayField.js.map +1 -0
- package/dist/components/AgentSchemaForm/inputs/ObjectField.d.ts +8 -0
- package/dist/components/AgentSchemaForm/inputs/ObjectField.d.ts.map +1 -0
- package/dist/components/AgentSchemaForm/inputs/ObjectField.js +75 -0
- package/dist/components/AgentSchemaForm/inputs/ObjectField.js.map +1 -0
- package/dist/components/AgentSchemaForm/inputs/validation.d.ts +10 -0
- package/dist/components/AgentSchemaForm/inputs/validation.d.ts.map +1 -0
- package/dist/components/AgentSchemaForm/inputs/validation.js +41 -0
- package/dist/components/AgentSchemaForm/inputs/validation.js.map +1 -0
- package/dist/components/AgentSchemaForm/resolveSchema.d.ts +7 -0
- package/dist/components/AgentSchemaForm/resolveSchema.d.ts.map +1 -0
- package/dist/components/AgentSchemaForm/resolveSchema.js +162 -0
- package/dist/components/AgentSchemaForm/resolveSchema.js.map +1 -0
- package/dist/components/AgentSchemaForm/types.d.ts +34 -0
- package/dist/components/AgentSchemaForm/types.d.ts.map +1 -0
- package/dist/components/AgentSchemaForm/types.js +8 -0
- package/dist/components/AgentSchemaForm/types.js.map +1 -0
- package/dist/components/FeedbackDialog.d.ts +2 -1
- package/dist/components/FeedbackDialog.d.ts.map +1 -1
- package/dist/components/FeedbackDialog.js +6 -2
- package/dist/components/FeedbackDialog.js.map +1 -1
- package/dist/components/InputsPage.d.ts +18 -0
- package/dist/components/InputsPage.d.ts.map +1 -0
- package/dist/components/InputsPage.js +32 -0
- package/dist/components/InputsPage.js.map +1 -0
- package/dist/components/Loader.d.ts +6 -0
- package/dist/components/Loader.d.ts.map +1 -0
- package/dist/components/Loader.js +6 -0
- package/dist/components/Loader.js.map +1 -0
- package/dist/components/SettingsDialog/InputsSection.d.ts +15 -0
- package/dist/components/SettingsDialog/InputsSection.d.ts.map +1 -0
- package/dist/components/SettingsDialog/InputsSection.js +29 -0
- package/dist/components/SettingsDialog/InputsSection.js.map +1 -0
- package/dist/components/SettingsDialog/ProfileSection.d.ts +7 -0
- package/dist/components/SettingsDialog/ProfileSection.d.ts.map +1 -0
- package/dist/components/SettingsDialog/ProfileSection.js +146 -0
- package/dist/components/SettingsDialog/ProfileSection.js.map +1 -0
- package/dist/components/SettingsDialog/SettingsDialog.d.ts +33 -0
- package/dist/components/SettingsDialog/SettingsDialog.d.ts.map +1 -0
- package/dist/components/SettingsDialog/SettingsDialog.js +18 -0
- package/dist/components/SettingsDialog/SettingsDialog.js.map +1 -0
- package/dist/components/SettingsDialog/index.d.ts +3 -0
- package/dist/components/SettingsDialog/index.d.ts.map +1 -0
- package/dist/components/SettingsDialog/index.js +2 -0
- package/dist/components/SettingsDialog/index.js.map +1 -0
- package/dist/components/ToolConfirmation.d.ts +20 -0
- package/dist/components/ToolConfirmation.d.ts.map +1 -0
- package/dist/components/ToolConfirmation.js +20 -0
- package/dist/components/ToolConfirmation.js.map +1 -0
- package/dist/components/ToolConfirmationRenderer.d.ts +15 -0
- package/dist/components/ToolConfirmationRenderer.d.ts.map +1 -0
- package/dist/components/ToolConfirmationRenderer.js +52 -0
- package/dist/components/ToolConfirmationRenderer.js.map +1 -0
- package/dist/components/agentUtils.d.ts +4 -0
- package/dist/components/agentUtils.d.ts.map +1 -0
- package/dist/components/agentUtils.js +24 -0
- package/dist/components/agentUtils.js.map +1 -0
- package/dist/components/useFavorites.d.ts +7 -0
- package/dist/components/useFavorites.d.ts.map +1 -0
- package/dist/components/useFavorites.js +47 -0
- package/dist/components/useFavorites.js.map +1 -0
- package/dist/constants/countries.d.ts +251 -0
- package/dist/constants/countries.d.ts.map +1 -0
- package/dist/constants/countries.js +250 -0
- package/dist/constants/countries.js.map +1 -0
- package/dist/hooks/useResolvedAgent.d.ts +34 -0
- package/dist/hooks/useResolvedAgent.d.ts.map +1 -0
- package/dist/hooks/useResolvedAgent.js +99 -0
- package/dist/hooks/useResolvedAgent.js.map +1 -0
- package/dist/i18n/i18n.config.d.ts +2 -0
- package/dist/i18n/i18n.config.d.ts.map +1 -0
- package/dist/i18n/i18n.config.js +24 -0
- package/dist/i18n/i18n.config.js.map +1 -0
- package/dist/i18n/index.d.ts +2 -0
- package/dist/i18n/index.d.ts.map +1 -0
- package/dist/i18n/index.js +2 -0
- package/dist/i18n/index.js.map +1 -0
- package/dist/i18n/locales/en/index.json +306 -0
- package/dist/i18n/locales/keys/index.json +306 -0
- package/dist/icons/ConversationalAgentIcon.d.ts +7 -0
- package/dist/icons/ConversationalAgentIcon.d.ts.map +1 -0
- package/dist/icons/ConversationalAgentIcon.js +8 -0
- package/dist/icons/ConversationalAgentIcon.js.map +1 -0
- package/dist/icons/TimeIcon.d.ts +2 -0
- package/dist/icons/TimeIcon.d.ts.map +1 -0
- package/dist/icons/TimeIcon.js +3 -0
- package/dist/icons/TimeIcon.js.map +1 -0
- package/dist/index.d.ts +10 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +90 -3
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -1
- package/dist/utils/normalizeValue.d.ts +7 -0
- package/dist/utils/normalizeValue.d.ts.map +1 -0
- package/dist/utils/normalizeValue.js +31 -0
- package/dist/utils/normalizeValue.js.map +1 -0
- package/dist/utils/resolveAgent.d.ts +17 -0
- package/dist/utils/resolveAgent.d.ts.map +1 -0
- package/dist/utils/resolveAgent.js +25 -0
- package/dist/utils/resolveAgent.js.map +1 -0
- package/dist/utils/telemetryUtils.d.ts +1 -1
- package/dist/utils/telemetryUtils.d.ts.map +1 -1
- package/dist/utils/telemetryUtils.js +2 -2
- package/dist/utils/telemetryUtils.js.map +1 -1
- package/dist/utils.d.ts +11 -3
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +36 -9
- package/dist/utils.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +10 -5
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { UiPath } from "@uipath/uipath-typescript/core";
|
|
3
|
+
import { useEffect, useState } from "react";
|
|
4
|
+
import { ConversationalAgentPickerChat } from "./ConversationalAgentPickerChat";
|
|
5
|
+
import "./ConversationalAgentChat.scss";
|
|
6
|
+
const ConversationalAgentPickerChatWithSdk = ({ baseUrl, orgName, tenantName, secret, ...pickerProps }) => {
|
|
7
|
+
const [state, setState] = useState({ sdk: null, error: null });
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
if (!baseUrl || !orgName || !tenantName || !secret) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
let cancelled = false;
|
|
13
|
+
const initSdk = async () => {
|
|
14
|
+
try {
|
|
15
|
+
const normalizedBaseUrl = baseUrl.match(/^https?:\/\//)
|
|
16
|
+
? baseUrl
|
|
17
|
+
: `https://${baseUrl}`;
|
|
18
|
+
const uipath = new UiPath({
|
|
19
|
+
baseUrl: normalizedBaseUrl,
|
|
20
|
+
orgName,
|
|
21
|
+
tenantName,
|
|
22
|
+
secret,
|
|
23
|
+
});
|
|
24
|
+
await uipath.initialize();
|
|
25
|
+
if (!cancelled) {
|
|
26
|
+
setState({ sdk: uipath, error: null });
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
catch (err) {
|
|
30
|
+
if (!cancelled) {
|
|
31
|
+
setState({
|
|
32
|
+
sdk: null,
|
|
33
|
+
error: err instanceof Error ? err.message : "Failed to initialize SDK",
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
initSdk();
|
|
39
|
+
return () => {
|
|
40
|
+
cancelled = true;
|
|
41
|
+
};
|
|
42
|
+
}, [baseUrl, orgName, tenantName, secret]);
|
|
43
|
+
const { sdk, error } = state;
|
|
44
|
+
if (!baseUrl || !orgName || !tenantName || !secret) {
|
|
45
|
+
return (_jsx("div", { style: { padding: 24, color: "#666" }, children: "Please provide baseUrl, orgName, tenantName, and secret in the controls panel below." }));
|
|
46
|
+
}
|
|
47
|
+
if (error) {
|
|
48
|
+
return (_jsxs("div", { style: { padding: 24, color: "#d32f2f" }, children: ["SDK initialization failed: ", error] }));
|
|
49
|
+
}
|
|
50
|
+
if (!sdk) {
|
|
51
|
+
return _jsx("div", { style: { padding: 24 }, children: "Initializing SDK..." });
|
|
52
|
+
}
|
|
53
|
+
return _jsx(ConversationalAgentPickerChat, { sdk: sdk, ...pickerProps });
|
|
54
|
+
};
|
|
55
|
+
const meta = {
|
|
56
|
+
title: "Components/ConversationalAgentPickerChat",
|
|
57
|
+
component: ConversationalAgentPickerChatWithSdk,
|
|
58
|
+
decorators: [
|
|
59
|
+
(Story) => (_jsx("div", { style: { height: "600px" }, children: _jsx(Story, {}) })),
|
|
60
|
+
],
|
|
61
|
+
parameters: {
|
|
62
|
+
layout: "padded",
|
|
63
|
+
docs: {
|
|
64
|
+
description: {
|
|
65
|
+
component: `
|
|
66
|
+
A React widget that lists conversational agents available on a given UiPath SDK and mounts \`ConversationalAgentChat\` for the selected agent.
|
|
67
|
+
|
|
68
|
+
## Features
|
|
69
|
+
|
|
70
|
+
- Lists all agents accessible to the provided SDK (across folders)
|
|
71
|
+
- Click an agent to open a chat with it
|
|
72
|
+
- Back button returns to the agent list
|
|
73
|
+
- Refetches and resets selection when the SDK prop changes
|
|
74
|
+
|
|
75
|
+
## Installation
|
|
76
|
+
|
|
77
|
+
\`\`\`bash
|
|
78
|
+
npm install @uipath/ui-widgets-conversational-agent-chat
|
|
79
|
+
\`\`\`
|
|
80
|
+
|
|
81
|
+
## Usage
|
|
82
|
+
|
|
83
|
+
> **Note:** Add either \`light\` or \`dark\` class to your HTML \`<body>\` element to enable proper theming.
|
|
84
|
+
|
|
85
|
+
\`\`\`tsx
|
|
86
|
+
import { ConversationalAgentPickerChat } from '@uipath/ui-widgets-conversational-agent-chat';
|
|
87
|
+
import "@uipath/ui-widgets-conversational-agent-chat/ConversationalAgentChat.css";
|
|
88
|
+
import { UiPath } from '@uipath/uipath-typescript/core';
|
|
89
|
+
|
|
90
|
+
function App() {
|
|
91
|
+
const sdk = new UiPath({
|
|
92
|
+
baseUrl: 'https://cloud.uipath.com',
|
|
93
|
+
orgName: 'your-org',
|
|
94
|
+
tenantName: 'your-tenant',
|
|
95
|
+
secret: 'your-secret'
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
await sdk.initialize();
|
|
99
|
+
|
|
100
|
+
return (
|
|
101
|
+
<ConversationalAgentPickerChat
|
|
102
|
+
sdk={sdk}
|
|
103
|
+
locale="en"
|
|
104
|
+
theme="light"
|
|
105
|
+
onAgentSelected={(agent) => console.log("picked", agent)}
|
|
106
|
+
/>
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
\`\`\`
|
|
110
|
+
|
|
111
|
+
## Requirements
|
|
112
|
+
|
|
113
|
+
- React 19.2.0+
|
|
114
|
+
- React DOM 19.2.0+
|
|
115
|
+
- @uipath/uipath-typescript
|
|
116
|
+
- @uipath/apollo-react
|
|
117
|
+
- @uipath/apollo-wind`,
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
tags: ["autodocs"],
|
|
122
|
+
argTypes: {
|
|
123
|
+
baseUrl: {
|
|
124
|
+
description: "UiPath API base URL",
|
|
125
|
+
control: "text",
|
|
126
|
+
table: { category: "SDK Configuration" },
|
|
127
|
+
},
|
|
128
|
+
orgName: {
|
|
129
|
+
description: "UiPath organization name",
|
|
130
|
+
control: "text",
|
|
131
|
+
table: { category: "SDK Configuration" },
|
|
132
|
+
},
|
|
133
|
+
tenantName: {
|
|
134
|
+
description: "UiPath tenant name",
|
|
135
|
+
control: "text",
|
|
136
|
+
table: { category: "SDK Configuration" },
|
|
137
|
+
},
|
|
138
|
+
secret: {
|
|
139
|
+
description: "UiPath API secret for authentication",
|
|
140
|
+
control: "text",
|
|
141
|
+
table: { category: "SDK Configuration" },
|
|
142
|
+
},
|
|
143
|
+
locale: {
|
|
144
|
+
description: "Locale for the chat UI",
|
|
145
|
+
control: "select",
|
|
146
|
+
options: [
|
|
147
|
+
"en",
|
|
148
|
+
"es",
|
|
149
|
+
"pt",
|
|
150
|
+
"de",
|
|
151
|
+
"fr",
|
|
152
|
+
"ja",
|
|
153
|
+
"ko",
|
|
154
|
+
"ru",
|
|
155
|
+
"tr",
|
|
156
|
+
"zh-CN",
|
|
157
|
+
"zh-TW",
|
|
158
|
+
"pt-BR",
|
|
159
|
+
"es-MX",
|
|
160
|
+
],
|
|
161
|
+
},
|
|
162
|
+
theme: {
|
|
163
|
+
description: "Visual theme for the chat UI",
|
|
164
|
+
control: "select",
|
|
165
|
+
options: ["light", "dark", "light-hc", "dark-hc"],
|
|
166
|
+
},
|
|
167
|
+
readOnly: {
|
|
168
|
+
description: "When true, disables user input in the chat view",
|
|
169
|
+
control: "boolean",
|
|
170
|
+
},
|
|
171
|
+
overrideLabels: {
|
|
172
|
+
description: "Override default labels for title, footer disclaimer, and input placeholder in the chat view",
|
|
173
|
+
control: "object",
|
|
174
|
+
},
|
|
175
|
+
},
|
|
176
|
+
args: {
|
|
177
|
+
baseUrl: "cloud.uipath.com",
|
|
178
|
+
orgName: "",
|
|
179
|
+
tenantName: "",
|
|
180
|
+
secret: "",
|
|
181
|
+
locale: "en",
|
|
182
|
+
theme: "light",
|
|
183
|
+
readOnly: false,
|
|
184
|
+
overrideLabels: undefined,
|
|
185
|
+
},
|
|
186
|
+
};
|
|
187
|
+
export default meta;
|
|
188
|
+
export const Default = {
|
|
189
|
+
parameters: {
|
|
190
|
+
docs: {
|
|
191
|
+
description: {
|
|
192
|
+
story: "Default picker. Fill in the SDK configuration in the controls panel to load the agent list.",
|
|
193
|
+
},
|
|
194
|
+
},
|
|
195
|
+
},
|
|
196
|
+
};
|
|
197
|
+
export const DarkTheme = {
|
|
198
|
+
args: {
|
|
199
|
+
theme: "dark",
|
|
200
|
+
},
|
|
201
|
+
parameters: {
|
|
202
|
+
docs: {
|
|
203
|
+
description: {
|
|
204
|
+
story: "Picker with the dark theme applied to the chat view.",
|
|
205
|
+
},
|
|
206
|
+
},
|
|
207
|
+
},
|
|
208
|
+
};
|
|
209
|
+
//# sourceMappingURL=ConversationalAgentPickerChat.stories.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConversationalAgentPickerChat.stories.js","sourceRoot":"","sources":["../src/ConversationalAgentPickerChat.stories.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,MAAM,EAAE,MAAM,gCAAgC,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AAChF,OAAO,gCAAgC,CAAC;AAaxC,MAAM,oCAAoC,GAAG,CAAC,EAC5C,OAAO,EACP,OAAO,EACP,UAAU,EACV,MAAM,EACN,GAAG,WAAW,EACyB,EAAE,EAAE;IAC3C,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAG/B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ACX,KAAK,EACH,6FAA6F;aAChG;SACF;KACF;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,SAAS,GAAU;IAC9B,IAAI,EAAE;QACJ,KAAK,EAAE,MAAM;KACd;IACD,UAAU,EAAE;QACV,IAAI,EAAE;YACJ,WAAW,EAAE;gBACX,KAAK,EAAE,sDAAsD;aAC9D;SACF;KACF;CACF,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { AgentSummary } from "../types";
|
|
2
|
+
interface AgentListProps {
|
|
3
|
+
agents: AgentSummary[];
|
|
4
|
+
onSelect: (agent: AgentSummary) => void;
|
|
5
|
+
favorites: Set<string>;
|
|
6
|
+
onToggleFavorite: (agent: AgentSummary) => void;
|
|
7
|
+
}
|
|
8
|
+
export declare const AgentList: ({ agents, onSelect, favorites, onToggleFavorite, }: AgentListProps) => import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=AgentList.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AgentList.d.ts","sourceRoot":"","sources":["../../src/components/AgentList.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAOxC,UAAU,cAAc;IACtB,MAAM,EAAE,YAAY,EAAE,CAAC;IACvB,QAAQ,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,CAAC;IACxC,SAAS,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACvB,gBAAgB,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,CAAC;CACjD;AA2DD,eAAO,MAAM,SAAS,GAAI,oDAKvB,cAAc,4CAiBhB,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Avatar, AvatarFallback, Card, CardDescription, } from "@uipath/apollo-wind";
|
|
3
|
+
import { agentKey, colorForName } from "./agentUtils";
|
|
4
|
+
const DEFAULT_NO_DESCRIPTION = "No description available";
|
|
5
|
+
const DEFAULT_ADD_TO_FAVORITES = "Add to favorites";
|
|
6
|
+
const DEFAULT_REMOVE_FROM_FAVORITES = "Remove from favorites";
|
|
7
|
+
const AgentCard = ({ agent, isFavorite, onSelect, onToggleFavorite, }) => {
|
|
8
|
+
const initial = agent.name.charAt(0).toUpperCase() || "?";
|
|
9
|
+
const color = colorForName(agent.name);
|
|
10
|
+
return (_jsxs(Card, { className: "relative transition-shadow hover:shadow-md focus-within:ring-2 focus-within:ring-ring", children: [_jsxs("button", { type: "button", onClick: () => onSelect(agent), className: "flex items-start gap-3 p-4 w-full text-left cursor-pointer rounded-[inherit] focus:outline-none", children: [_jsx(Avatar, { className: "h-12 w-12 rounded-md", children: _jsx(AvatarFallback, { className: "rounded-md text-white font-semibold text-base", style: { backgroundColor: color }, children: initial }) }), _jsxs("div", { className: "flex-1 min-w-0 pr-6", children: [_jsx("div", { className: "font-semibold truncate", children: agent.name }), _jsx(CardDescription, { className: "line-clamp-2 mt-1", children: agent.description || DEFAULT_NO_DESCRIPTION })] })] }), _jsx("button", { type: "button", className: `absolute top-3 right-3 text-lg leading-none rounded-sm focus:outline-none focus-visible:ring-2 focus-visible:ring-ring ${isFavorite
|
|
11
|
+
? "text-amber-500"
|
|
12
|
+
: "text-muted-foreground hover:text-foreground"}`, onClick: () => onToggleFavorite(agent), "aria-label": isFavorite ? DEFAULT_REMOVE_FROM_FAVORITES : DEFAULT_ADD_TO_FAVORITES, children: isFavorite ? "★" : "☆" })] }));
|
|
13
|
+
};
|
|
14
|
+
export const AgentList = ({ agents, onSelect, favorites, onToggleFavorite, }) => {
|
|
15
|
+
return (_jsx("div", { className: "grid gap-4 grid-cols-[repeat(auto-fill,minmax(320px,1fr))]", children: agents.map((agent) => {
|
|
16
|
+
const key = agentKey(agent);
|
|
17
|
+
return (_jsx(AgentCard, { agent: agent, isFavorite: favorites.has(key), onSelect: onSelect, onToggleFavorite: onToggleFavorite }, key));
|
|
18
|
+
}) }));
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=AgentList.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AgentList.js","sourceRoot":"","sources":["../../src/components/AgentList.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,MAAM,EACN,cAAc,EACd,IAAI,EACJ,eAAe,GAChB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEtD,MAAM,sBAAsB,GAAG,0BAA0B,CAAC;AAC1D,MAAM,wBAAwB,GAAG,kBAAkB,CAAC;AACpD,MAAM,6BAA6B,GAAG,uBAAuB,CAAC;AAgB9D,MAAM,SAAS,GAAG,CAAC,EACjB,KAAK,EACL,UAAU,EACV,QAAQ,EACR,gBAAgB,GACD,EAAE,EAAE;IACnB,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,IAAI,GAAG,CAAC;IAC1D,MAAM,KAAK,GAAG,YAAY,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAEvC,OAAO,CACL,MAAC,IAAI,IAAC,SAAS,EAAC,uFAAuF,aACrG,kBACE,IAAI,EAAC,QAAQ,EACb,OAAO,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,EAC9B,SAAS,EAAC,iGAAiG,aAE3G,KAAC,MAAM,IAAC,SAAS,EAAC,sBAAsB,YACtC,KAAC,cAAc,IACb,SAAS,EAAC,+CAA+C,EACzD,KAAK,EAAE,EAAE,eAAe,EAAE,KAAK,EAAE,YAEhC,OAAO,GACO,GACV,EACT,eAAK,SAAS,EAAC,qBAAqB,aAClC,cAAK,SAAS,EAAC,wBAAwB,YAAE,KAAK,CAAC,IAAI,GAAO,EAC1D,KAAC,eAAe,IAAC,SAAS,EAAC,mBAAmB,YAC3C,KAAK,CAAC,WAAW,IAAI,sBAAsB,GAC5B,IACd,IACC,EACT,iBACE,IAAI,EAAC,QAAQ,EACb,SAAS,EAAE,0HACT,UAAU;oBACR,CAAC,CAAC,gBAAgB;oBAClB,CAAC,CAAC,6CACN,EAAE,EACF,OAAO,EAAE,GAAG,EAAE,CAAC,gBAAgB,CAAC,KAAK,CAAC,gBAEpC,UAAU,CAAC,CAAC,CAAC,6BAA6B,CAAC,CAAC,CAAC,wBAAwB,YAItE,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,GAChB,IACJ,CACR,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,EACxB,MAAM,EACN,QAAQ,EACR,SAAS,EACT,gBAAgB,GACD,EAAE,EAAE;IACnB,OAAO,CACL,cAAK,SAAS,EAAC,4DAA4D,YACxE,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;YACpB,MAAM,GAAG,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;YAC5B,OAAO,CACL,KAAC,SAAS,IAER,KAAK,EAAE,KAAK,EACZ,UAAU,EAAE,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,EAC9B,QAAQ,EAAE,QAAQ,EAClB,gBAAgB,EAAE,gBAAgB,IAJ7B,GAAG,CAKR,CACH,CAAC;QACJ,CAAC,CAAC,GACE,CACP,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { InputSchemaProperty } from "./types";
|
|
2
|
+
export type { InputSchemaProperty } from "./types";
|
|
3
|
+
export interface AgentSchemaFieldProps {
|
|
4
|
+
prop: InputSchemaProperty;
|
|
5
|
+
fieldKey: string;
|
|
6
|
+
isRequired?: boolean;
|
|
7
|
+
value: unknown;
|
|
8
|
+
onChange: (value: unknown) => void;
|
|
9
|
+
onValidationError?: (hasError: boolean) => void;
|
|
10
|
+
error?: boolean;
|
|
11
|
+
/** Flat dot-notation error map relative to this field */
|
|
12
|
+
errorMap?: Record<string, boolean>;
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
}
|
|
15
|
+
type DateFormat = "date" | "time" | "datetime-local";
|
|
16
|
+
interface FieldLabelProps {
|
|
17
|
+
prop: InputSchemaProperty;
|
|
18
|
+
fieldKey: string;
|
|
19
|
+
isRequired?: boolean;
|
|
20
|
+
hasError?: boolean;
|
|
21
|
+
/** Resolved date/time format (schema-driven if set, else inferred from value). */
|
|
22
|
+
dateFormat?: DateFormat;
|
|
23
|
+
}
|
|
24
|
+
export declare const FieldLabel: ({ prop, fieldKey, isRequired, hasError, dateFormat, }: FieldLabelProps) => import("react/jsx-runtime").JSX.Element;
|
|
25
|
+
export declare const AgentSchemaField: ({ prop, fieldKey, isRequired, value, onChange, onValidationError, error, errorMap, disabled, }: AgentSchemaFieldProps) => import("react/jsx-runtime").JSX.Element;
|
|
26
|
+
//# sourceMappingURL=AgentSchemaField.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AgentSchemaField.d.ts","sourceRoot":"","sources":["../../../src/components/AgentSchemaForm/AgentSchemaField.tsx"],"names":[],"mappings":"AA6BA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AACnD,YAAY,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAEnD,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,mBAAmB,CAAC;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,KAAK,EAAE,OAAO,CAAC;IACf,QAAQ,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IACnC,iBAAiB,CAAC,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAC;IAChD,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,yDAAyD;IACzD,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAgBD,KAAK,UAAU,GAAG,MAAM,GAAG,MAAM,GAAG,gBAAgB,CAAC;AA2CrD,UAAU,eAAe;IACvB,IAAI,EAAE,mBAAmB,CAAC;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,kFAAkF;IAClF,UAAU,CAAC,EAAE,UAAU,CAAC;CACzB;AAED,eAAO,MAAM,UAAU,GAAI,uDAMxB,eAAe,4CAejB,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAI,gGAU9B,qBAAqB,4CA2KvB,CAAC"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Input, RadioGroup, RadioGroupItem, Select, SelectContent, SelectItem, SelectTrigger, SelectValue, cn, } from "@uipath/apollo-wind";
|
|
3
|
+
import { useTranslation } from "react-i18next";
|
|
4
|
+
import { DataTypesArray, DataTypesBoolean, DataTypesDate, DataTypesDatetime, DataTypesInteger, DataTypesObject, DataTypesString, } from "@uipath/apollo-react/icons";
|
|
5
|
+
// No apollo equivalent for a time-only type, so this one stays hand-rolled.
|
|
6
|
+
import { TimeIcon } from "../../icons/TimeIcon";
|
|
7
|
+
import { FieldShell } from "./FieldShell";
|
|
8
|
+
import { ArrayField } from "./inputs/ArrayField";
|
|
9
|
+
import { ObjectField } from "./inputs/ObjectField";
|
|
10
|
+
const hasAnyRequiredDescendant = (prop) => {
|
|
11
|
+
if (prop.type !== "object")
|
|
12
|
+
return false;
|
|
13
|
+
const required = prop.required ?? [];
|
|
14
|
+
if (required.length > 0)
|
|
15
|
+
return true;
|
|
16
|
+
const nestedProps = prop.properties;
|
|
17
|
+
if (!nestedProps)
|
|
18
|
+
return false;
|
|
19
|
+
return Object.values(nestedProps).some(hasAnyRequiredDescendant);
|
|
20
|
+
};
|
|
21
|
+
// Tool input schemas often arrive as plain `type: "string"` with no format,
|
|
22
|
+
// even when the value is a date. Precedence: schema → value → undefined.
|
|
23
|
+
// length >= 10 avoids bare years like "2026" matching as parseable dates.
|
|
24
|
+
//
|
|
25
|
+
// `format: "time"` is intentionally not trusted — calendar-style tool schemas
|
|
26
|
+
// commonly misuse it for timezone identifier strings ("Europe/London"). A
|
|
27
|
+
// genuine time-only value flows through the value check below and renders as
|
|
28
|
+
// text.
|
|
29
|
+
const resolveDateFormat = (prop, value) => {
|
|
30
|
+
if (prop.format === "date")
|
|
31
|
+
return "date";
|
|
32
|
+
if (prop.format === "date-time")
|
|
33
|
+
return "datetime-local";
|
|
34
|
+
if (prop.type && prop.type !== "string")
|
|
35
|
+
return undefined;
|
|
36
|
+
if (value instanceof Date)
|
|
37
|
+
return "datetime-local";
|
|
38
|
+
if (typeof value === "string" &&
|
|
39
|
+
value.length >= 10 &&
|
|
40
|
+
!isNaN(Date.parse(value))) {
|
|
41
|
+
return value.includes("T") ? "datetime-local" : "date";
|
|
42
|
+
}
|
|
43
|
+
return undefined;
|
|
44
|
+
};
|
|
45
|
+
const getFieldIcon = (prop, dateFormat) => {
|
|
46
|
+
if (prop.type === "boolean")
|
|
47
|
+
return _jsx(DataTypesBoolean, { size: 16 });
|
|
48
|
+
if (prop.type === "number" || prop.type === "integer")
|
|
49
|
+
return _jsx(DataTypesInteger, { size: 16 });
|
|
50
|
+
if (dateFormat === "date")
|
|
51
|
+
return _jsx(DataTypesDate, { size: 16 });
|
|
52
|
+
if (dateFormat === "time")
|
|
53
|
+
return _jsx(TimeIcon, {});
|
|
54
|
+
if (dateFormat === "datetime-local")
|
|
55
|
+
return _jsx(DataTypesDatetime, { size: 16 });
|
|
56
|
+
if (prop.type === "array")
|
|
57
|
+
return _jsx(DataTypesArray, { size: 16 });
|
|
58
|
+
if (prop.type === "object")
|
|
59
|
+
return _jsx(DataTypesObject, { size: 16 });
|
|
60
|
+
return _jsx(DataTypesString, { size: 16 });
|
|
61
|
+
};
|
|
62
|
+
export const FieldLabel = ({ prop, fieldKey, isRequired, hasError = false, dateFormat, }) => {
|
|
63
|
+
return (_jsxs("span", { className: cn("flex items-center gap-2", hasError ? "text-destructive" : "text-muted-foreground"), children: [getFieldIcon(prop, dateFormat), _jsxs("span", { children: [prop.title || fieldKey, isRequired && _jsx("span", { children: "*" })] })] }));
|
|
64
|
+
};
|
|
65
|
+
export const AgentSchemaField = ({ prop, fieldKey, isRequired, value, onChange, onValidationError, error = false, errorMap, disabled, }) => {
|
|
66
|
+
const { t } = useTranslation();
|
|
67
|
+
const showRequired = isRequired || hasAnyRequiredDescendant(prop);
|
|
68
|
+
const dateFormat = resolveDateFormat(prop, value);
|
|
69
|
+
const label = (_jsx(FieldLabel, { prop: prop, fieldKey: fieldKey, isRequired: showRequired, hasError: error, dateFormat: dateFormat }));
|
|
70
|
+
if (prop.type === "boolean") {
|
|
71
|
+
return (_jsx(FieldShell, { label: label, error: error, disabled: disabled, helperText: prop.description, children: _jsxs(RadioGroup, { className: "flex gap-4", value: value === undefined ? "" : String(value), onValueChange: (nextValue) => onChange(nextValue === "true"), disabled: disabled, children: [_jsxs("label", { className: "flex items-center gap-2 text-sm", children: [_jsx(RadioGroupItem, { value: "true" }), t("agent_schema_boolean_true")] }), _jsxs("label", { className: "flex items-center gap-2 text-sm", children: [_jsx(RadioGroupItem, { value: "false" }), t("agent_schema_boolean_false")] })] }) }));
|
|
72
|
+
}
|
|
73
|
+
if (dateFormat) {
|
|
74
|
+
return (_jsx(FieldShell, { label: label, error: error, disabled: disabled, helperText: prop.description, children: _jsx(Input, { type: dateFormat, value: value ?? "", disabled: disabled, onChange: (e) => onChange(e.target.value), className: cn("relative w-full bg-background pr-10", "[&::-webkit-calendar-picker-indicator]:absolute", "[&::-webkit-calendar-picker-indicator]:right-3", "[&::-webkit-calendar-picker-indicator]:top-1/2", "[&::-webkit-calendar-picker-indicator]:-translate-y-1/2", error && "border-destructive focus-visible:ring-destructive") }) }));
|
|
75
|
+
}
|
|
76
|
+
if (prop.type === "object") {
|
|
77
|
+
return (_jsx(ObjectField, { prop: prop, fieldKey: fieldKey, isRequired: isRequired, value: value, onChange: onChange, onValidationError: onValidationError, error: error, errorMap: errorMap, disabled: disabled, label: label }));
|
|
78
|
+
}
|
|
79
|
+
if (prop.type === "array") {
|
|
80
|
+
return (_jsx(ArrayField, { prop: prop, fieldKey: fieldKey, isRequired: isRequired, value: value, onChange: onChange, onValidationError: onValidationError, error: error, disabled: disabled, label: label }));
|
|
81
|
+
}
|
|
82
|
+
if (prop.enum) {
|
|
83
|
+
const enumValues = prop.enum;
|
|
84
|
+
const oneOfOptions = (prop.oneOf ?? []);
|
|
85
|
+
const oneOfMap = new Map(oneOfOptions.map((o) => [o.const, o.title ?? o.const]));
|
|
86
|
+
return (_jsx(FieldShell, { label: label, error: error, disabled: disabled, helperText: prop.description, children: _jsxs(Select, { value: value === undefined ? "" : String(value), onValueChange: onChange, disabled: disabled, children: [_jsx(SelectTrigger, { className: cn("w-full bg-background", error && "border-destructive focus:ring-destructive"), children: _jsx(SelectValue, { placeholder: t("agent_schema_select_placeholder") }) }), _jsx(SelectContent, { children: enumValues.map((opt) => (_jsx(SelectItem, { value: opt, children: oneOfMap.get(opt) ?? opt }, opt))) })] }) }));
|
|
87
|
+
}
|
|
88
|
+
const isNumeric = prop.type === "number" || prop.type === "integer";
|
|
89
|
+
return (_jsx(FieldShell, { label: label, error: error, disabled: disabled, helperText: prop.description, children: _jsx(Input, { value: value === undefined ? "" : String(value), type: isNumeric ? "number" : "text", disabled: disabled, onChange: (e) => {
|
|
90
|
+
const val = e.target.value;
|
|
91
|
+
onChange(isNumeric ? (val === "" ? undefined : Number(val)) : val);
|
|
92
|
+
}, placeholder: isNumeric
|
|
93
|
+
? t("agent_schema_number_placeholder")
|
|
94
|
+
: t("agent_schema_text_placeholder"), className: cn("bg-background", error && "border-destructive focus-visible:ring-destructive") }) }));
|
|
95
|
+
};
|
|
96
|
+
//# sourceMappingURL=AgentSchemaField.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AgentSchemaField.js","sourceRoot":"","sources":["../../../src/components/AgentSchemaForm/AgentSchemaField.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,KAAK,EACL,UAAU,EACV,cAAc,EACd,MAAM,EACN,aAAa,EACb,UAAU,EACV,aAAa,EACb,WAAW,EACX,EAAE,GACH,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/C,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,aAAa,EACb,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EACf,eAAe,GAChB,MAAM,4BAA4B,CAAC;AAEpC,4EAA4E;AAC5E,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAiBnD,MAAM,wBAAwB,GAAG,CAAC,IAAyB,EAAW,EAAE;IACtE,IAAI,IAAI,CAAC,IAAI,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IACzC,MAAM,QAAQ,GAAI,IAAI,CAAC,QAAiC,IAAI,EAAE,CAAC;IAC/D,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC;IACrC,MAAM,WAAW,GAAG,IAAI,CAAC,UAEZ,CAAC;IACd,IAAI,CAAC,WAAW;QAAE,OAAO,KAAK,CAAC;IAC/B,OAAO,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;AACnE,CAAC,CAAC;AAOF,4EAA4E;AAC5E,yEAAyE;AACzE,0EAA0E;AAC1E,EAAE;AACF,8EAA8E;A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C,CAAC,GAAG,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;YACrE,CAAC,EACD,WAAW,EACT,SAAS;gBACP,CAAC,CAAC,CAAC,CAAC,iCAAiC,CAAC;gBACtC,CAAC,CAAC,CAAC,CAAC,+BAA+B,CAAC,EAExC,SAAS,EAAE,EAAE,CACX,eAAe,EACf,KAAK,IAAI,mDAAmD,CAC7D,GACD,GACS,CACd,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { InputSchema } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Handle exposed via the `formRef` prop.
|
|
4
|
+
* Allows external components to trigger form submission
|
|
5
|
+
* programmatically while AgentSchemaForm handles validation.
|
|
6
|
+
*/
|
|
7
|
+
export interface AgentSchemaFormHandle {
|
|
8
|
+
/** Triggers validation and calls onSubmit if valid. */
|
|
9
|
+
submit: () => void;
|
|
10
|
+
}
|
|
11
|
+
export interface AgentSchemaFormProps {
|
|
12
|
+
/** JSON Schema describing the agent's input fields. */
|
|
13
|
+
inputSchema: InputSchema;
|
|
14
|
+
/** Pre-populated values for form fields (e.g. from tool call inputValue). */
|
|
15
|
+
initialValues?: Record<string, unknown>;
|
|
16
|
+
/** Called with the validated form data on submit. */
|
|
17
|
+
onSubmit?: (data: Record<string, unknown>) => void | Promise<void>;
|
|
18
|
+
/** Disable all form fields. */
|
|
19
|
+
disabled?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* When true, optional fields are hidden behind a "Show more" toggle.
|
|
22
|
+
* Used at agent launch; settings mode shows all fields.
|
|
23
|
+
*/
|
|
24
|
+
collapsibleOptional?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Ref exposing a `submit()` method for programmatic submission.
|
|
27
|
+
* Use when rendering your own submit button outside the form.
|
|
28
|
+
*/
|
|
29
|
+
formRef?: React.Ref<AgentSchemaFormHandle>;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Reusable schema-driven form for UiPath Conversational Agents.
|
|
33
|
+
*
|
|
34
|
+
* Renders input fields from a JSON Schema using Apollo Wind components. Currently used by InputsPage, settings
|
|
35
|
+
* panel, and tool call confirmation.
|
|
36
|
+
*/
|
|
37
|
+
export declare function AgentSchemaForm({ inputSchema, initialValues, onSubmit, disabled, collapsibleOptional, formRef, }: AgentSchemaFormProps): import("react/jsx-runtime").JSX.Element;
|
|
38
|
+
//# sourceMappingURL=AgentSchemaForm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AgentSchemaForm.d.ts","sourceRoot":"","sources":["../../../src/components/AgentSchemaForm/AgentSchemaForm.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAoB3C;;;;GAIG;AACH,MAAM,WAAW,qBAAqB;IACpC,uDAAuD;IACvD,MAAM,EAAE,MAAM,IAAI,CAAC;CACpB;AAED,MAAM,WAAW,oBAAoB;IACnC,uDAAuD;IACvD,WAAW,EAAE,WAAW,CAAC;IACzB,6EAA6E;IAC7E,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACxC,qDAAqD;IACrD,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACnE,+BAA+B;IAC/B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B;;;OAGG;IACH,OAAO,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC;CAC5C;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,EAC9B,WAAW,EACX,aAAa,EACb,QAAQ,EACR,QAAQ,EACR,mBAA2B,EAC3B,OAAO,GACR,EAAE,oBAAoB,2CAwJtB"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Collapsible, CollapsibleContent, CollapsibleTrigger, cn, } from "@uipath/apollo-wind";
|
|
3
|
+
import { ChevronDown, ChevronRight } from "@uipath/apollo-react/icons";
|
|
4
|
+
import { useCallback, useImperativeHandle, useMemo, useState } from "react";
|
|
5
|
+
import { useTranslation } from "react-i18next";
|
|
6
|
+
import { AgentSchemaField } from "./AgentSchemaField";
|
|
7
|
+
import { isFieldEmpty, collectRequiredErrors } from "./inputs/validation";
|
|
8
|
+
import { resolveSchema } from "./resolveSchema";
|
|
9
|
+
/**
|
|
10
|
+
* Returns a new error map with the given key removed along with any nested
|
|
11
|
+
* errors written under it (dot-notation children like `parent.child`).
|
|
12
|
+
*/
|
|
13
|
+
function clearErrorsForKey(errors, key) {
|
|
14
|
+
const prefix = `${key}.`;
|
|
15
|
+
const next = { ...errors };
|
|
16
|
+
delete next[key];
|
|
17
|
+
for (const k of Object.keys(next)) {
|
|
18
|
+
if (k.startsWith(prefix))
|
|
19
|
+
delete next[k];
|
|
20
|
+
}
|
|
21
|
+
return next;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Reusable schema-driven form for UiPath Conversational Agents.
|
|
25
|
+
*
|
|
26
|
+
* Renders input fields from a JSON Schema using Apollo Wind components. Currently used by InputsPage, settings
|
|
27
|
+
* panel, and tool call confirmation.
|
|
28
|
+
*/
|
|
29
|
+
export function AgentSchemaForm({ inputSchema, initialValues, onSubmit, disabled, collapsibleOptional = false, formRef, }) {
|
|
30
|
+
const { t } = useTranslation();
|
|
31
|
+
const [formData, setFormData] = useState(() => {
|
|
32
|
+
const init = { ...(initialValues ?? {}) };
|
|
33
|
+
// Pre-initialize object-type properties to {} so ObjectField
|
|
34
|
+
// doesn't need a mount-time side effect to set its own default.
|
|
35
|
+
const resolved = resolveSchema(inputSchema);
|
|
36
|
+
for (const [key, prop] of Object.entries(resolved.properties ?? {})) {
|
|
37
|
+
if (prop.type === "object" && init[key] === undefined) {
|
|
38
|
+
init[key] = {};
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return init;
|
|
42
|
+
});
|
|
43
|
+
const [showOptional, setShowOptional] = useState(false);
|
|
44
|
+
const [fieldErrors, setFieldErrors] = useState({});
|
|
45
|
+
const [validationErrors, setValidationErrors] = useState({});
|
|
46
|
+
const schema = useMemo(() => resolveSchema(inputSchema), [inputSchema]);
|
|
47
|
+
const properties = useMemo(() => schema.properties ?? {}, [schema]);
|
|
48
|
+
const requiredKeys = useMemo(() => schema.required ?? [], [schema]);
|
|
49
|
+
const entries = Object.entries(properties);
|
|
50
|
+
const requiredEntries = entries.filter(([key]) => requiredKeys.includes(key));
|
|
51
|
+
const optionalEntries = entries.filter(([key]) => !requiredKeys.includes(key));
|
|
52
|
+
const handleSubmit = useCallback(async () => {
|
|
53
|
+
const errors = {};
|
|
54
|
+
// Validate required fields
|
|
55
|
+
requiredKeys.forEach((key) => {
|
|
56
|
+
const value = formData[key];
|
|
57
|
+
const prop = properties[key];
|
|
58
|
+
if (isFieldEmpty(value)) {
|
|
59
|
+
errors[key] = true;
|
|
60
|
+
}
|
|
61
|
+
if (prop?.type === "object") {
|
|
62
|
+
collectRequiredErrors(value, prop, key, errors);
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
// Check inline validation errors (e.g. JSON syntax)
|
|
66
|
+
Object.entries(validationErrors).forEach(([key, hasError]) => {
|
|
67
|
+
if (hasError)
|
|
68
|
+
errors[key] = true;
|
|
69
|
+
});
|
|
70
|
+
if (Object.keys(errors).length > 0) {
|
|
71
|
+
setFieldErrors(errors);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
setFieldErrors({});
|
|
75
|
+
await onSubmit?.(formData);
|
|
76
|
+
}, [formData, validationErrors, requiredKeys, properties, onSubmit]);
|
|
77
|
+
// imperative needed here since the button is outside the form
|
|
78
|
+
useImperativeHandle(formRef, () => ({ submit: handleSubmit }), [
|
|
79
|
+
handleSubmit,
|
|
80
|
+
]);
|
|
81
|
+
const renderField = (key, prop, isRequired) => {
|
|
82
|
+
const hasError = fieldErrors[key] ?? false;
|
|
83
|
+
const prefix = `${key}.`;
|
|
84
|
+
const errorMap = Object.fromEntries(Object.entries(fieldErrors)
|
|
85
|
+
.filter(([k]) => k.startsWith(prefix))
|
|
86
|
+
.map(([k, v]) => [k.slice(prefix.length), v]));
|
|
87
|
+
// Nested objects/arrays render their own grid inside, so they take the
|
|
88
|
+
// full row. Scalars (string/number/boolean/date) share a row in pairs.
|
|
89
|
+
const isFullSpan = prop.type === "object" || prop.type === "array";
|
|
90
|
+
return (_jsx("div", { className: isFullSpan ? "col-span-2" : "col-span-1", children: _jsx(AgentSchemaField, { prop: prop, fieldKey: key, isRequired: isRequired, value: formData[key], onChange: (val) => {
|
|
91
|
+
setFormData((prev) => ({ ...prev, [key]: val }));
|
|
92
|
+
if (val !== undefined && val !== "" && val !== null) {
|
|
93
|
+
setFieldErrors((prev) => clearErrorsForKey(prev, key));
|
|
94
|
+
}
|
|
95
|
+
}, onValidationError: (hasValidationError) => setValidationErrors((prev) => ({
|
|
96
|
+
...prev,
|
|
97
|
+
[key]: hasValidationError,
|
|
98
|
+
})), error: hasError, errorMap: Object.keys(errorMap).length > 0 ? errorMap : undefined, disabled: disabled }) }, key));
|
|
99
|
+
};
|
|
100
|
+
return (_jsx("div", { className: "uipath-cas-schema-form w-full", children: _jsxs("div", { className: "uipath-cas-schema-grid my-1 grid w-full grid-cols-1 gap-4", children: [requiredEntries.map(([key, prop]) => renderField(key, prop, true)), collapsibleOptional && optionalEntries.length > 0 && (_jsxs(Collapsible, { open: showOptional, onOpenChange: setShowOptional, className: "col-span-2", children: [_jsxs(CollapsibleTrigger, { className: cn("flex w-full items-center gap-1 py-2 text-left text-sm font-semibold", "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"), children: [_jsx("span", { children: showOptional
|
|
101
|
+
? t("agent_schema_show_less")
|
|
102
|
+
: t("agent_schema_show_more") }), showOptional ? (_jsx(ChevronDown, { size: 18 })) : (_jsx(ChevronRight, { size: 18 }))] }), _jsx(CollapsibleContent, { children: _jsx("div", { className: "uipath-cas-schema-grid grid grid-cols-1 gap-4", children: optionalEntries.map(([key, prop]) => renderField(key, prop, false)) }) })] })), !collapsibleOptional &&
|
|
103
|
+
optionalEntries.map(([key, prop]) => renderField(key, prop, false))] }) }));
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=AgentSchemaForm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AgentSchemaForm.js","sourceRoot":"","sources":["../../../src/components/AgentSchemaForm/AgentSchemaForm.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,WAAW,EACX,kBAAkB,EAClB,kBAAkB,EAClB,EAAE,GACH,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AACvE,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5E,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,OAAO,EAAE,YAAY,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAE1E,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD;;;GAGG;AACH,SAAS,iBAAiB,CACxB,MAA+B,EAC/B,GAAW;IAEX,MAAM,MAAM,GAAG,GAAG,GAAG,GAAG,CAAC;IACzB,MAAM,IAAI,GAAG,EAAE,GAAG,MAAM,EAAE,CAAC;IAC3B,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;IACjB,KA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+B,YAC5C,eAAK,SAAS,EAAC,2DAA2D,aACvE,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE,EAAE,CACnC,WAAW,CAAC,GAAG,EAAE,IAA2B,EAAE,IAAI,CAAC,CACpD,EACA,mBAAmB,IAAI,eAAe,CAAC,MAAM,GAAG,CAAC,IAAI,CACpD,MAAC,WAAW,IACV,IAAI,EAAE,YAAY,EAClB,YAAY,EAAE,eAAe,EAC7B,SAAS,EAAC,YAAY,aAEtB,MAAC,kBAAkB,IACjB,SAAS,EAAE,EAAE,CACX,qEAAqE,EACrE,qGAAqG,CACtG,aAED,yBACG,YAAY;wCACX,CAAC,CAAC,CAAC,CAAC,wBAAwB,CAAC;wCAC7B,CAAC,CAAC,CAAC,CAAC,wBAAwB,CAAC,GAC1B,EACN,YAAY,CAAC,CAAC,CAAC,CACd,KAAC,WAAW,IAAC,IAAI,EAAE,EAAE,GAAI,CAC1B,CAAC,CAAC,CAAC,CACF,KAAC,YAAY,IAAC,IAAI,EAAE,EAAE,GAAI,CAC3B,IACkB,EACrB,KAAC,kBAAkB,cACjB,cAAK,SAAS,EAAC,+CAA+C,YAC3D,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE,EAAE,CACnC,WAAW,CAAC,GAAG,EAAE,IAA2B,EAAE,KAAK,CAAC,CACrD,GACG,GACa,IACT,CACf,EACA,CAAC,mBAAmB;oBACnB,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE,EAAE,CAClC,WAAW,CAAC,GAAG,EAAE,IAA2B,EAAE,KAAK,CAAC,CACrD,IACC,GACF,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { StoryObj } from "@storybook/react-vite";
|
|
2
|
+
import type { InputSchema } from "./types";
|
|
3
|
+
declare const meta: {
|
|
4
|
+
title: string;
|
|
5
|
+
component: ({ inputSchema, initialValues, disabled, collapsibleOptional, }: {
|
|
6
|
+
inputSchema: InputSchema;
|
|
7
|
+
initialValues?: Record<string, unknown>;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
collapsibleOptional?: boolean;
|
|
10
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
parameters: {
|
|
12
|
+
layout: string;
|
|
13
|
+
docs: {
|
|
14
|
+
description: {
|
|
15
|
+
component: string;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
tags: string[];
|
|
20
|
+
};
|
|
21
|
+
export default meta;
|
|
22
|
+
type Story = StoryObj<typeof meta>;
|
|
23
|
+
export declare const AllFieldTypes: Story;
|
|
24
|
+
export declare const NestedObject: Story;
|
|
25
|
+
export declare const EnumWithLabels: Story;
|
|
26
|
+
export declare const CollapsibleOptional: Story;
|
|
27
|
+
export declare const PrePopulated: Story;
|
|
28
|
+
export declare const Disabled: Story;
|
|
29
|
+
export declare const RefAndNullableSchema: Story;
|
|
30
|
+
//# sourceMappingURL=AgentSchemaForm.stories.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AgentSchemaForm.stories.d.ts","sourceRoot":"","sources":["../../../src/components/AgentSchemaForm/AgentSchemaForm.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAQ,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAG5D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAuD3C,QAAA,MAAM,IAAI;;gFA7CP;QACD,WAAW,EAAE,WAAW,CAAC;QACzB,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACxC,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,mBAAmB,CAAC,EAAE,OAAO,CAAC;KAC/B;;;;;;;;;;CAqDgC,CAAC;AAElC,eAAe,IAAI,CAAC;AACpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAC;AAEnC,eAAO,MAAM,aAAa,EAAE,KA8B3B,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,KAmC1B,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,KA0B5B,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,KA0BjC,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,KA2B1B,CAAC;AAEF,eAAO,MAAM,QAAQ,EAAE,KAgCtB,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,KA2BlC,CAAC"}
|