@m6d/cortex-react 0.6.1 → 0.8.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 +24 -0
- package/dist/index.d.ts +33 -2
- package/dist/index.js +12 -8
- package/dist/styles.css +419 -128
- package/dist/theme.css +9 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -24,6 +24,30 @@ export function Chat() {
|
|
|
24
24
|
|
|
25
25
|
`CortexReactConfig` is the shared `CortexConfig` plus a React-only `toolComponents` slot (`Record<string, ComponentType<CortexToolComponentInputs>>`). Every other property, the client tools flow, and the media blocks are documented in [`packages/cortex-angular/README.md`](../cortex-angular/README.md); only the `toolComponents` and `injector` rows are Angular-specific.
|
|
26
26
|
|
|
27
|
+
## Custom header
|
|
28
|
+
|
|
29
|
+
`renderHeader` replaces the header on both screens, the chat and the history,
|
|
30
|
+
and receives the same context the Angular `cortexHeader` template does (fields
|
|
31
|
+
listed in the Angular README):
|
|
32
|
+
|
|
33
|
+
```tsx
|
|
34
|
+
<CortexChatWidget
|
|
35
|
+
config={config}
|
|
36
|
+
renderHeader={(chat) => (
|
|
37
|
+
<div className="cortex-widget__chat-header">
|
|
38
|
+
<div className="cortex-widget__chat-title-wrap">
|
|
39
|
+
<p className="cortex-widget__chat-title">{chat.title ?? chat.agentName}</p>
|
|
40
|
+
</div>
|
|
41
|
+
<button className="cortex-widget__header-btn" onClick={chat.newChat}>
|
|
42
|
+
+
|
|
43
|
+
</button>
|
|
44
|
+
</div>
|
|
45
|
+
)}
|
|
46
|
+
/>
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
The theming tokens and the table actions are the same as Angular's.
|
|
50
|
+
|
|
27
51
|
## Requirements
|
|
28
52
|
|
|
29
53
|
- React 18 or later
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Generated by dts-bundle-generator v9.5.1
|
|
2
2
|
|
|
3
3
|
import { ToolCallPart, UIMessage } from '@tanstack/ai';
|
|
4
|
-
import { ComponentType } from 'react';
|
|
4
|
+
import { ComponentType, ReactNode } from 'react';
|
|
5
5
|
|
|
6
6
|
declare const LOCALES: readonly [
|
|
7
7
|
"en",
|
|
@@ -45,6 +45,31 @@ export type MediaRenderers = Partial<Record<string, MediaRenderer>>;
|
|
|
45
45
|
export type Localized<T> = T | Partial<Record<Locale, T>>;
|
|
46
46
|
export type CortexViewMode = "helper" | "full";
|
|
47
47
|
export type CortexTheme = "light" | "dark" | "system";
|
|
48
|
+
/**
|
|
49
|
+
* What a host's own header receives in place of the widget's: where the
|
|
50
|
+
* widget is, what to show, and the actions the default header offers. One
|
|
51
|
+
* header serves both screens; `screen` says which is showing.
|
|
52
|
+
*/
|
|
53
|
+
export type CortexHeaderContext = {
|
|
54
|
+
screen: "chat" | "threads";
|
|
55
|
+
viewMode: CortexViewMode;
|
|
56
|
+
/** The open thread's title; null on a new chat. */
|
|
57
|
+
title: string | null;
|
|
58
|
+
/** `agentName` in the widget's locale. */
|
|
59
|
+
agentName: string | undefined;
|
|
60
|
+
isWorking: boolean;
|
|
61
|
+
/** Whether the host enabled the debug switch, and whether it is on. */
|
|
62
|
+
debug: {
|
|
63
|
+
shown: boolean;
|
|
64
|
+
on: boolean;
|
|
65
|
+
};
|
|
66
|
+
newChat: () => void;
|
|
67
|
+
/** Shows the history: the history screen, or in full mode the sidebar where it is hidden. */
|
|
68
|
+
openHistory: () => void;
|
|
69
|
+
/** Returns to the open chat from wherever `openHistory` went. */
|
|
70
|
+
closeHistory: () => void;
|
|
71
|
+
toggleDebug: () => void;
|
|
72
|
+
};
|
|
48
73
|
export type CortexToolCallContext = {
|
|
49
74
|
threadId: string;
|
|
50
75
|
};
|
|
@@ -112,11 +137,17 @@ export type CortexConfig = {
|
|
|
112
137
|
export type CortexReactConfig = CortexConfig & {
|
|
113
138
|
toolComponents?: Record<string, ComponentType<CortexToolComponentInputs>>;
|
|
114
139
|
};
|
|
140
|
+
export type HeaderRenderer = (chat: CortexHeaderContext) => ReactNode;
|
|
115
141
|
/** The chat widget: the thread list, the open conversation and its composer, for the agent `config` points at. */
|
|
116
|
-
export declare function CortexChatWidget({ config, className, }: {
|
|
142
|
+
export declare function CortexChatWidget({ config, className, renderHeader, }: {
|
|
117
143
|
config: CortexReactConfig;
|
|
118
144
|
/** Sizing classes for the host. */
|
|
119
145
|
className?: string;
|
|
146
|
+
/**
|
|
147
|
+
* The host's own header. When given it replaces the default on both the
|
|
148
|
+
* chat and the history screen, and receives the widget's state and actions.
|
|
149
|
+
*/
|
|
150
|
+
renderHeader?: HeaderRenderer;
|
|
120
151
|
}): import("react").JSX.Element;
|
|
121
152
|
|
|
122
153
|
export {};
|