@asgard-js/react 0.2.40-canary.1 → 0.2.40-canary.2
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 +32 -54
- package/dist/components/chatbot/chatbot-footer/chatbot-footer.d.ts +5 -1
- package/dist/components/chatbot/chatbot-footer/chatbot-footer.d.ts.map +1 -1
- package/dist/components/chatbot/chatbot.d.ts +4 -5
- package/dist/components/chatbot/chatbot.d.ts.map +1 -1
- package/dist/index.js +6038 -6035
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -292,6 +292,7 @@ config: {
|
|
|
292
292
|
- `onRunDone?`: `DoneEventHandler` - Handler for run completion events
|
|
293
293
|
- `onRunError?`: `ErrorEventHandler` - Error handler for execution errors
|
|
294
294
|
- **customActions?**: `ReactNode[]` - Custom actions to display on the chatbot header
|
|
295
|
+
- **customFooterActions?**: `ReactNode[]` - Custom action buttons rendered alongside the built-in footer attachment buttons (upload / export / document). Each item is a `ReactNode`; the consumer controls styling. Mirrors the pattern of `customActions`. See [Custom Footer Actions](#custom-footer-actions) section for details.
|
|
295
296
|
- **enableLoadConfigFromService?**: `boolean` - Enable loading configuration from service
|
|
296
297
|
- **enableUpload?**: `boolean` - Enable file upload functionality. When set, it takes priority over the `embedConfig.enableUpload` setting from the bot provider metadata. Defaults to `false` if not specified in either location. Supports image files (JPEG, PNG, GIF, WebP) up to 20MB per file, maximum 10 files at once.
|
|
297
298
|
- **enableExport?**: `boolean` - Enable conversation export functionality. When set, it takes priority over the `embedConfig.enableExport` setting from the bot provider metadata. Defaults to `false` if not specified in either location. Adds a download button to the chatbot footer that exports the conversation history as a Markdown file with timestamps and trace IDs.
|
|
@@ -318,7 +319,6 @@ config: {
|
|
|
318
319
|
- **messageActions?**: `(message: ConversationBotMessage) => MessageActionConfig[]` - Function to define which action buttons to display for each bot message. Returns an array of `{ id: string, label: string }` objects. See [Message Actions](#message-actions) section for details.
|
|
319
320
|
- **onMessageAction?**: `(actionId: string, message: ConversationBotMessage) => void` - Callback when a message action button is clicked. Receives the action ID and the associated bot message.
|
|
320
321
|
- **renderHeader?**: `() => ReactNode` - Custom header renderer. When provided, completely replaces the default header. Use `useAsgardContext()` inside the render function to access `resetChannel`, `isResetting`, and other internal state.
|
|
321
|
-
- **renderFooter?**: `() => ReactNode` - Custom footer renderer. When provided, completely replaces the default footer. Use `useAsgardContext()` inside the render function to access `sendMessage`, `isConnecting`, `pendingInputValue`, `setPendingInputValue`, etc. See [Custom Footer](#custom-footer) section for details.
|
|
322
322
|
- **renderMenu?**: `() => ReactNode` - Custom menu renderer. When provided, renders content between the chat body and footer. Useful for quick menus, suggested questions, or navigation panels. See [Custom Menu](#custom-menu) section for details.
|
|
323
323
|
- **renderMessageContent?**: `(props: MessageContentRendererProps) => ReactNode` - Custom renderer for message content. Allows customizing how messages are rendered based on message properties. See [Custom Message Renderer](#custom-message-renderer) section for details.
|
|
324
324
|
- **renderToolCallGroup?**: `(props: ToolCallGroupRendererProps) => ReactNode` - Custom renderer for tool call group. Return `null` to hide, return JSX to fully customize, or call `renderDefaultContent()` to use the default UI with optional overrides (e.g., `renderDefaultContent({ title: 'AI is thinking...' })`). See [Tool Call Group Renderer](#tool-call-group-renderer) section for details.
|
|
@@ -1321,74 +1321,52 @@ const App = () => {
|
|
|
1321
1321
|
};
|
|
1322
1322
|
```
|
|
1323
1323
|
|
|
1324
|
-
<a id="custom-footer"></a>
|
|
1324
|
+
<a id="custom-footer-actions"></a>
|
|
1325
1325
|
<br/>
|
|
1326
1326
|
|
|
1327
|
-
### Custom Footer
|
|
1327
|
+
### Custom Footer Actions
|
|
1328
1328
|
|
|
1329
|
-
The `
|
|
1329
|
+
The `customFooterActions` prop adds extra buttons to the built-in footer alongside the default attachment buttons (upload / export / document). The rest of the footer — textarea, IME composition handling, send button, mic button, drag-and-drop — stays untouched. This is the right tool for the common "I just want to add a button" case; if you need to fully replace the footer, that requires a different (not-yet-shipped) prop.
|
|
1330
1330
|
|
|
1331
|
-
|
|
1331
|
+
Items are plain `ReactNode`s; the consumer styles each button as they like.
|
|
1332
1332
|
|
|
1333
1333
|
#### Usage Example
|
|
1334
1334
|
|
|
1335
1335
|
```typescript
|
|
1336
|
-
import {
|
|
1337
|
-
import { Chatbot, useAsgardContext } from '@asgard-js/react';
|
|
1338
|
-
|
|
1339
|
-
function CustomFooter() {
|
|
1340
|
-
const { sendMessage, isConnecting, pendingInputValue, setPendingInputValue } = useAsgardContext();
|
|
1341
|
-
const [value, setValue] = useState('');
|
|
1342
|
-
const textareaRef = useRef<HTMLTextAreaElement>(null);
|
|
1343
|
-
|
|
1344
|
-
useEffect(() => {
|
|
1345
|
-
if (pendingInputValue === null) return;
|
|
1346
|
-
|
|
1347
|
-
setValue(pendingInputValue);
|
|
1348
|
-
setPendingInputValue(null);
|
|
1349
|
-
textareaRef.current?.focus();
|
|
1350
|
-
}, [pendingInputValue, setPendingInputValue]);
|
|
1351
|
-
|
|
1352
|
-
const isPreviewMode = !sendMessage;
|
|
1353
|
-
const trimmed = value.trim();
|
|
1354
|
-
const disabled = isPreviewMode || isConnecting || !trimmed;
|
|
1355
|
-
|
|
1356
|
-
const submit = () => {
|
|
1357
|
-
if (disabled) return;
|
|
1336
|
+
import { Chatbot } from '@asgard-js/react';
|
|
1358
1337
|
|
|
1359
|
-
|
|
1360
|
-
|
|
1338
|
+
const App = () => {
|
|
1339
|
+
const handleExportPdf = (): void => {
|
|
1340
|
+
// ...
|
|
1361
1341
|
};
|
|
1362
1342
|
|
|
1363
1343
|
return (
|
|
1364
|
-
<
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1344
|
+
<Chatbot
|
|
1345
|
+
config={{
|
|
1346
|
+
apiKey: 'your-api-key',
|
|
1347
|
+
botProviderEndpoint: 'https://api.asgard-ai.com/ns/{namespace}/bot-provider/{botProviderId}',
|
|
1348
|
+
}}
|
|
1349
|
+
customChannelId="your-channel-id"
|
|
1350
|
+
customFooterActions={[
|
|
1351
|
+
<button key="pdf" onClick={handleExportPdf} title="Export PDF">
|
|
1352
|
+
📄
|
|
1353
|
+
</button>,
|
|
1354
|
+
<button key="bookmark" onClick={() => console.log('Bookmark')} title="Bookmark">
|
|
1355
|
+
🔖
|
|
1356
|
+
</button>,
|
|
1357
|
+
]}
|
|
1358
|
+
/>
|
|
1377
1359
|
);
|
|
1378
|
-
}
|
|
1379
|
-
|
|
1380
|
-
const App = () => (
|
|
1381
|
-
<Chatbot
|
|
1382
|
-
config={{
|
|
1383
|
-
apiKey: 'your-api-key',
|
|
1384
|
-
botProviderEndpoint: 'https://api.asgard-ai.com/ns/{namespace}/bot-provider/{botProviderId}',
|
|
1385
|
-
}}
|
|
1386
|
-
customChannelId="your-channel-id"
|
|
1387
|
-
renderFooter={() => <CustomFooter />}
|
|
1388
|
-
/>
|
|
1389
|
-
);
|
|
1360
|
+
};
|
|
1390
1361
|
```
|
|
1391
1362
|
|
|
1363
|
+
#### Notes
|
|
1364
|
+
|
|
1365
|
+
- Items render in the same row as the built-in attachment buttons (after upload / export / document, before the textarea).
|
|
1366
|
+
- They do **not** participate in the built-in collapse-into-`+`-menu logic; they always render inline. Avoid passing many items, or the row may overflow.
|
|
1367
|
+
- When the chatbot is in preview mode (`sendMessage` unavailable) the built-in buttons remain visible but inert. Your custom buttons stay clickable — disable them yourself if that matters.
|
|
1368
|
+
- For the rare case where you need a completely different input UX (e.g. structured form, code editor), this prop is not enough; use `useAsgardContext()` to read SDK state and build something on the side, or open an issue for a `renderFooter` escape hatch.
|
|
1369
|
+
|
|
1392
1370
|
<a id="custom-menu"></a>
|
|
1393
1371
|
<br/>
|
|
1394
1372
|
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
interface ChatbotFooterProps {
|
|
4
|
+
customFooterActions?: ReactNode[];
|
|
5
|
+
}
|
|
6
|
+
export declare function ChatbotFooter({ customFooterActions }?: ChatbotFooterProps): ReactNode;
|
|
7
|
+
export {};
|
|
4
8
|
//# sourceMappingURL=chatbot-footer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chatbot-footer.d.ts","sourceRoot":"","sources":["../../../../src/components/chatbot/chatbot-footer/chatbot-footer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,SAAS,EAMV,MAAM,OAAO,CAAC;AA0Bf,wBAAgB,aAAa,
|
|
1
|
+
{"version":3,"file":"chatbot-footer.d.ts","sourceRoot":"","sources":["../../../../src/components/chatbot/chatbot-footer/chatbot-footer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,SAAS,EAMV,MAAM,OAAO,CAAC;AA0Bf,UAAU,kBAAkB;IAC1B,mBAAmB,CAAC,EAAE,SAAS,EAAE,CAAC;CACnC;AAED,wBAAgB,aAAa,CAAC,EAAE,mBAAmB,EAAE,GAAE,kBAAuB,GAAG,SAAS,CA43BzF"}
|
|
@@ -53,12 +53,11 @@ interface ChatbotProps extends AsgardTemplateContextValue {
|
|
|
53
53
|
/** Custom header renderer. When provided, replaces the default header entirely. */
|
|
54
54
|
renderHeader?: () => ReactNode;
|
|
55
55
|
/**
|
|
56
|
-
* Custom
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
* etc. Mirrors the pattern of `renderHeader`.
|
|
56
|
+
* Custom action buttons rendered alongside the built-in footer buttons
|
|
57
|
+
* (upload / export / document). Each item is a ReactNode and the consumer
|
|
58
|
+
* controls styling. Mirrors the pattern of `customActions` (header).
|
|
60
59
|
*/
|
|
61
|
-
|
|
60
|
+
customFooterActions?: ReactNode[];
|
|
62
61
|
/** Custom menu renderer. When provided, renders between chat body and footer. */
|
|
63
62
|
renderMenu?: () => ReactNode;
|
|
64
63
|
/** Custom renderer for tool call group. Return null to hide, or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