@kite-copilot/chat-panel 0.1.2 → 0.2.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/README.md +186 -9
- package/dist/auto.cjs +3638 -0
- package/dist/auto.d.cts +60 -0
- package/dist/auto.d.ts +60 -0
- package/dist/auto.js +23 -0
- package/dist/chunk-R73Y24JS.js +3665 -0
- package/dist/createKiteChat-CFo7NUHz.d.cts +254 -0
- package/dist/createKiteChat-CFo7NUHz.d.ts +254 -0
- package/dist/embed.global.js +22 -23
- package/dist/index.cjs +3718 -0
- package/dist/index.d.cts +179 -0
- package/dist/index.d.ts +90 -287
- package/dist/index.js +67 -2737
- package/dist/styles.css +1 -1
- package/package.json +34 -23
- package/dist/index.d.mts +0 -376
- package/dist/index.js.map +0 -1
- package/dist/index.mjs +0 -2692
- package/dist/index.mjs.map +0 -1
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
|
|
3
|
+
type Page = "dashboard" | "customers" | "payments" | "settings" | "support" | "disputes" | "radar";
|
|
4
|
+
type SettingsTab = "general" | "billing" | "security" | "api" | "notifications" | "integrations";
|
|
5
|
+
type NavigationTarget = {
|
|
6
|
+
page: Page;
|
|
7
|
+
subtab?: SettingsTab;
|
|
8
|
+
};
|
|
9
|
+
type ActionType = "updateCompanyInfo" | "addApiKey" | "addCustomer" | "enable2FA" | "disable2FA" | "changePassword" | "revokeSession" | "toggleNotification" | "connectIntegration" | "disconnectIntegration" | "addPaymentMethod" | "removePaymentMethod" | "deleteApiKey" | "addWebhook" | "updateCurrency" | "updateTimezone" | "refundPayment" | "createSubscription" | "exportCertificate" | "toggleBlockRule" | "enableBlockRule" | "disableBlockRule";
|
|
10
|
+
type CompanyInfoData = {
|
|
11
|
+
companyName?: string;
|
|
12
|
+
email?: string;
|
|
13
|
+
address?: string;
|
|
14
|
+
phone?: string;
|
|
15
|
+
website?: string;
|
|
16
|
+
};
|
|
17
|
+
type ApiKeyData = {
|
|
18
|
+
name?: string;
|
|
19
|
+
keyId?: string;
|
|
20
|
+
};
|
|
21
|
+
type CustomerData = {
|
|
22
|
+
name?: string;
|
|
23
|
+
email?: string;
|
|
24
|
+
location?: string;
|
|
25
|
+
subscription?: "Starter" | "Professional" | "Enterprise";
|
|
26
|
+
};
|
|
27
|
+
type PasswordData = {
|
|
28
|
+
currentPassword?: string;
|
|
29
|
+
newPassword?: string;
|
|
30
|
+
confirmPassword?: string;
|
|
31
|
+
};
|
|
32
|
+
type NotificationData = {
|
|
33
|
+
notificationType?: "paymentReceived" | "paymentFailed" | "invoicePaid" | "monthlySummary" | "productUpdates";
|
|
34
|
+
enabled?: boolean;
|
|
35
|
+
};
|
|
36
|
+
type IntegrationData = {
|
|
37
|
+
integrationName?: "Slack" | "Zapier" | "Webhook";
|
|
38
|
+
};
|
|
39
|
+
type SessionData = {
|
|
40
|
+
sessionId?: string;
|
|
41
|
+
device?: string;
|
|
42
|
+
};
|
|
43
|
+
type PaymentMethodData = {
|
|
44
|
+
cardNumber?: string;
|
|
45
|
+
expiryDate?: string;
|
|
46
|
+
};
|
|
47
|
+
type WebhookData = {
|
|
48
|
+
url?: string;
|
|
49
|
+
name?: string;
|
|
50
|
+
};
|
|
51
|
+
type CurrencyData = {
|
|
52
|
+
currency?: "USD" | "EUR" | "GBP" | "JPY";
|
|
53
|
+
};
|
|
54
|
+
type TimezoneData = {
|
|
55
|
+
timezone?: "America/Los_Angeles" | "America/New_York" | "Europe/London" | "Asia/Tokyo";
|
|
56
|
+
};
|
|
57
|
+
type RefundData = {
|
|
58
|
+
transactionId?: string;
|
|
59
|
+
customer?: string;
|
|
60
|
+
amount?: string;
|
|
61
|
+
reason?: string;
|
|
62
|
+
};
|
|
63
|
+
type SubscriptionData = {
|
|
64
|
+
customerEmail?: string;
|
|
65
|
+
customerId?: string;
|
|
66
|
+
plan?: "Starter" | "Professional" | "Enterprise";
|
|
67
|
+
billingCycle?: "monthly" | "yearly";
|
|
68
|
+
};
|
|
69
|
+
type CertificateData = {
|
|
70
|
+
format?: "pdf" | "json";
|
|
71
|
+
};
|
|
72
|
+
type BlockRuleData = {
|
|
73
|
+
ruleId?: string;
|
|
74
|
+
ruleName?: string;
|
|
75
|
+
disabled?: boolean;
|
|
76
|
+
};
|
|
77
|
+
type ActionData = CompanyInfoData | ApiKeyData | CustomerData | PasswordData | NotificationData | IntegrationData | SessionData | PaymentMethodData | WebhookData | CurrencyData | TimezoneData | RefundData | SubscriptionData | CertificateData | BlockRuleData;
|
|
78
|
+
type StartingQuestion = {
|
|
79
|
+
id: string;
|
|
80
|
+
label: string;
|
|
81
|
+
prompt: string;
|
|
82
|
+
icon?: "layout" | "upload" | "setup" | "default";
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
interface ChatPanelProps {
|
|
86
|
+
/** Whether the panel is open (controlled mode) */
|
|
87
|
+
isOpen?: boolean;
|
|
88
|
+
/** Callback when the panel should close */
|
|
89
|
+
onClose?: () => void;
|
|
90
|
+
onBack?: () => void;
|
|
91
|
+
onNavigate?: (page: Page, subtab?: SettingsTab) => void;
|
|
92
|
+
onActionComplete?: (actionType: ActionType, data: ActionData) => void;
|
|
93
|
+
currentPage?: Page;
|
|
94
|
+
agentUrl?: string;
|
|
95
|
+
/** Custom starting questions (fetched per-user from backend) */
|
|
96
|
+
startingQuestions?: StartingQuestion[];
|
|
97
|
+
/** API endpoint to fetch starting questions */
|
|
98
|
+
startingQuestionsEndpoint?: string;
|
|
99
|
+
}
|
|
100
|
+
declare function ChatPanel({ isOpen, onClose, onBack, onNavigate, onActionComplete, currentPage, agentUrl, startingQuestions: startingQuestionsProp, startingQuestionsEndpoint }?: ChatPanelProps): react_jsx_runtime.JSX.Element;
|
|
101
|
+
/**
|
|
102
|
+
* PanelToggle - An arrow button on the right edge that toggles the side panel
|
|
103
|
+
* Shows left arrow when closed (click to open), right arrow when open (click to close)
|
|
104
|
+
* Uses fixed positioning to sit on the right edge of the viewport
|
|
105
|
+
*/
|
|
106
|
+
interface PanelToggleProps {
|
|
107
|
+
isOpen: boolean;
|
|
108
|
+
onClick: () => void;
|
|
109
|
+
className?: string;
|
|
110
|
+
}
|
|
111
|
+
declare function PanelToggle({ isOpen, onClick, className }: PanelToggleProps): react_jsx_runtime.JSX.Element;
|
|
112
|
+
/**
|
|
113
|
+
* ChatPanelWithToggle - Complete side panel with integrated toggle button
|
|
114
|
+
*
|
|
115
|
+
* This component renders a toggle arrow on the right side of the screen
|
|
116
|
+
* and a side panel that expands/collapses without overlaying existing content.
|
|
117
|
+
* When opened, it automatically adds padding to the body to push content left.
|
|
118
|
+
*
|
|
119
|
+
* Usage:
|
|
120
|
+
* ```tsx
|
|
121
|
+
* // Just drop it anywhere in your app - no layout changes needed
|
|
122
|
+
* function App() {
|
|
123
|
+
* return (
|
|
124
|
+
* <>
|
|
125
|
+
* <YourExistingApp />
|
|
126
|
+
* <ChatPanelWithToggle agentUrl="..." />
|
|
127
|
+
* </>
|
|
128
|
+
* );
|
|
129
|
+
* }
|
|
130
|
+
* ```
|
|
131
|
+
*/
|
|
132
|
+
interface ChatPanelWithToggleProps {
|
|
133
|
+
onNavigate?: (page: Page, subtab?: SettingsTab) => void;
|
|
134
|
+
onActionComplete?: (actionType: ActionType, data: ActionData) => void;
|
|
135
|
+
currentPage?: Page;
|
|
136
|
+
agentUrl?: string;
|
|
137
|
+
startingQuestions?: StartingQuestion[];
|
|
138
|
+
startingQuestionsEndpoint?: string;
|
|
139
|
+
/** Initial open state (default: false) */
|
|
140
|
+
defaultOpen?: boolean;
|
|
141
|
+
/** Controlled open state */
|
|
142
|
+
isOpen?: boolean;
|
|
143
|
+
/** Callback when panel open state changes */
|
|
144
|
+
onOpenChange?: (isOpen: boolean) => void;
|
|
145
|
+
}
|
|
146
|
+
declare function ChatPanelWithToggle({ onNavigate, onActionComplete, currentPage, agentUrl, startingQuestions, startingQuestionsEndpoint, defaultOpen, isOpen: controlledIsOpen, onOpenChange }: ChatPanelWithToggleProps): react_jsx_runtime.JSX.Element;
|
|
147
|
+
/**
|
|
148
|
+
* @deprecated Use ChatPanelWithToggle instead for the new side panel UX
|
|
149
|
+
*/
|
|
150
|
+
interface HelpButtonProps {
|
|
151
|
+
onClick: () => void;
|
|
152
|
+
className?: string;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* @deprecated Use ChatPanelWithToggle instead for the new side panel UX
|
|
156
|
+
*/
|
|
157
|
+
declare function HelpButton({ onClick, className }: HelpButtonProps): react_jsx_runtime.JSX.Element;
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* @kite-copilot/chat-panel - Programmatic API
|
|
161
|
+
*
|
|
162
|
+
* Industry-standard SDK pattern for embedding the Kite chat widget.
|
|
163
|
+
* No globals, explicit lifecycle control, tree-shakeable.
|
|
164
|
+
*
|
|
165
|
+
* Usage:
|
|
166
|
+
* ```ts
|
|
167
|
+
* import { createKiteChat } from '@kite-copilot/chat-panel';
|
|
168
|
+
* import '@kite-copilot/chat-panel/style.css';
|
|
169
|
+
*
|
|
170
|
+
* const chat = createKiteChat({
|
|
171
|
+
* userId: 'user-123',
|
|
172
|
+
* orgId: 'org-456',
|
|
173
|
+
* agentUrl: 'https://api.example.com',
|
|
174
|
+
* onNavigate: (page) => router.push(`/${page}`),
|
|
175
|
+
* });
|
|
176
|
+
*
|
|
177
|
+
* chat.mount('#chat-container');
|
|
178
|
+
* chat.open(); // Opens the side panel
|
|
179
|
+
* chat.close(); // Closes the side panel
|
|
180
|
+
* chat.setCurrentPage('settings');
|
|
181
|
+
* chat.unmount();
|
|
182
|
+
* ```
|
|
183
|
+
*/
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Configuration options for the Kite chat widget.
|
|
187
|
+
*/
|
|
188
|
+
interface KiteChatConfig {
|
|
189
|
+
/** Unique identifier for the current user */
|
|
190
|
+
userId: string;
|
|
191
|
+
/** Organization identifier */
|
|
192
|
+
orgId: string;
|
|
193
|
+
/** Backend agent API URL (defaults to http://localhost:5002) */
|
|
194
|
+
agentUrl?: string;
|
|
195
|
+
/** Current page context for the chat (e.g., 'dashboard', 'settings') */
|
|
196
|
+
currentPage?: string;
|
|
197
|
+
/** Theme mode */
|
|
198
|
+
theme?: 'light' | 'dark' | 'system';
|
|
199
|
+
/** Callback when the chat suggests navigation */
|
|
200
|
+
onNavigate?: (page: string, subtab?: string) => void;
|
|
201
|
+
/** Callback when an action is completed */
|
|
202
|
+
onActionComplete?: (actionType: ActionType, data: ActionData) => void;
|
|
203
|
+
/** Custom starting questions (fetched per-user from backend) */
|
|
204
|
+
startingQuestions?: StartingQuestion[];
|
|
205
|
+
/** API endpoint to fetch starting questions */
|
|
206
|
+
startingQuestionsEndpoint?: string;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Instance returned by createKiteChat with lifecycle control methods.
|
|
210
|
+
*/
|
|
211
|
+
interface KiteChatInstance {
|
|
212
|
+
/** Mount the chat widget into a container element */
|
|
213
|
+
mount: (container: string | HTMLElement) => void;
|
|
214
|
+
/** Unmount and clean up the chat widget */
|
|
215
|
+
unmount: () => void;
|
|
216
|
+
/** Open the side panel */
|
|
217
|
+
open: () => void;
|
|
218
|
+
/** Close the side panel */
|
|
219
|
+
close: () => void;
|
|
220
|
+
/** Toggle the side panel */
|
|
221
|
+
toggle: () => void;
|
|
222
|
+
/** Check if the panel is open */
|
|
223
|
+
isOpen: () => boolean;
|
|
224
|
+
/** Update the current page context */
|
|
225
|
+
setCurrentPage: (page: string) => void;
|
|
226
|
+
/** Update configuration (userId, orgId, callbacks, etc.) */
|
|
227
|
+
updateConfig: (config: Partial<KiteChatConfig>) => void;
|
|
228
|
+
/** Check if the widget is currently mounted */
|
|
229
|
+
isMounted: () => boolean;
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Create a new Kite chat widget instance.
|
|
233
|
+
*
|
|
234
|
+
* This is the primary API for embedding the chat widget.
|
|
235
|
+
* Returns an instance with explicit lifecycle control.
|
|
236
|
+
*
|
|
237
|
+
* @param config - Configuration options
|
|
238
|
+
* @returns KiteChatInstance with mount/unmount/update methods
|
|
239
|
+
*
|
|
240
|
+
* @example
|
|
241
|
+
* ```ts
|
|
242
|
+
* const chat = createKiteChat({
|
|
243
|
+
* userId: 'user-123',
|
|
244
|
+
* orgId: 'org-456',
|
|
245
|
+
* onNavigate: (page) => router.push(`/${page}`)
|
|
246
|
+
* });
|
|
247
|
+
*
|
|
248
|
+
* chat.mount('#chat-container');
|
|
249
|
+
* chat.open(); // Open the side panel
|
|
250
|
+
* ```
|
|
251
|
+
*/
|
|
252
|
+
declare function createKiteChat(config: KiteChatConfig): KiteChatInstance;
|
|
253
|
+
|
|
254
|
+
export { type ActionType as A, ChatPanel as C, HelpButton as H, type KiteChatConfig as K, type NavigationTarget as N, PanelToggle as P, type SettingsTab as S, type KiteChatInstance as a, ChatPanelWithToggle as b, createKiteChat as c, type ChatPanelProps as d, type ChatPanelWithToggleProps as e, type PanelToggleProps as f, type HelpButtonProps as g, type Page as h, type ActionData as i, type StartingQuestion as j };
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
|
|
3
|
+
type Page = "dashboard" | "customers" | "payments" | "settings" | "support" | "disputes" | "radar";
|
|
4
|
+
type SettingsTab = "general" | "billing" | "security" | "api" | "notifications" | "integrations";
|
|
5
|
+
type NavigationTarget = {
|
|
6
|
+
page: Page;
|
|
7
|
+
subtab?: SettingsTab;
|
|
8
|
+
};
|
|
9
|
+
type ActionType = "updateCompanyInfo" | "addApiKey" | "addCustomer" | "enable2FA" | "disable2FA" | "changePassword" | "revokeSession" | "toggleNotification" | "connectIntegration" | "disconnectIntegration" | "addPaymentMethod" | "removePaymentMethod" | "deleteApiKey" | "addWebhook" | "updateCurrency" | "updateTimezone" | "refundPayment" | "createSubscription" | "exportCertificate" | "toggleBlockRule" | "enableBlockRule" | "disableBlockRule";
|
|
10
|
+
type CompanyInfoData = {
|
|
11
|
+
companyName?: string;
|
|
12
|
+
email?: string;
|
|
13
|
+
address?: string;
|
|
14
|
+
phone?: string;
|
|
15
|
+
website?: string;
|
|
16
|
+
};
|
|
17
|
+
type ApiKeyData = {
|
|
18
|
+
name?: string;
|
|
19
|
+
keyId?: string;
|
|
20
|
+
};
|
|
21
|
+
type CustomerData = {
|
|
22
|
+
name?: string;
|
|
23
|
+
email?: string;
|
|
24
|
+
location?: string;
|
|
25
|
+
subscription?: "Starter" | "Professional" | "Enterprise";
|
|
26
|
+
};
|
|
27
|
+
type PasswordData = {
|
|
28
|
+
currentPassword?: string;
|
|
29
|
+
newPassword?: string;
|
|
30
|
+
confirmPassword?: string;
|
|
31
|
+
};
|
|
32
|
+
type NotificationData = {
|
|
33
|
+
notificationType?: "paymentReceived" | "paymentFailed" | "invoicePaid" | "monthlySummary" | "productUpdates";
|
|
34
|
+
enabled?: boolean;
|
|
35
|
+
};
|
|
36
|
+
type IntegrationData = {
|
|
37
|
+
integrationName?: "Slack" | "Zapier" | "Webhook";
|
|
38
|
+
};
|
|
39
|
+
type SessionData = {
|
|
40
|
+
sessionId?: string;
|
|
41
|
+
device?: string;
|
|
42
|
+
};
|
|
43
|
+
type PaymentMethodData = {
|
|
44
|
+
cardNumber?: string;
|
|
45
|
+
expiryDate?: string;
|
|
46
|
+
};
|
|
47
|
+
type WebhookData = {
|
|
48
|
+
url?: string;
|
|
49
|
+
name?: string;
|
|
50
|
+
};
|
|
51
|
+
type CurrencyData = {
|
|
52
|
+
currency?: "USD" | "EUR" | "GBP" | "JPY";
|
|
53
|
+
};
|
|
54
|
+
type TimezoneData = {
|
|
55
|
+
timezone?: "America/Los_Angeles" | "America/New_York" | "Europe/London" | "Asia/Tokyo";
|
|
56
|
+
};
|
|
57
|
+
type RefundData = {
|
|
58
|
+
transactionId?: string;
|
|
59
|
+
customer?: string;
|
|
60
|
+
amount?: string;
|
|
61
|
+
reason?: string;
|
|
62
|
+
};
|
|
63
|
+
type SubscriptionData = {
|
|
64
|
+
customerEmail?: string;
|
|
65
|
+
customerId?: string;
|
|
66
|
+
plan?: "Starter" | "Professional" | "Enterprise";
|
|
67
|
+
billingCycle?: "monthly" | "yearly";
|
|
68
|
+
};
|
|
69
|
+
type CertificateData = {
|
|
70
|
+
format?: "pdf" | "json";
|
|
71
|
+
};
|
|
72
|
+
type BlockRuleData = {
|
|
73
|
+
ruleId?: string;
|
|
74
|
+
ruleName?: string;
|
|
75
|
+
disabled?: boolean;
|
|
76
|
+
};
|
|
77
|
+
type ActionData = CompanyInfoData | ApiKeyData | CustomerData | PasswordData | NotificationData | IntegrationData | SessionData | PaymentMethodData | WebhookData | CurrencyData | TimezoneData | RefundData | SubscriptionData | CertificateData | BlockRuleData;
|
|
78
|
+
type StartingQuestion = {
|
|
79
|
+
id: string;
|
|
80
|
+
label: string;
|
|
81
|
+
prompt: string;
|
|
82
|
+
icon?: "layout" | "upload" | "setup" | "default";
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
interface ChatPanelProps {
|
|
86
|
+
/** Whether the panel is open (controlled mode) */
|
|
87
|
+
isOpen?: boolean;
|
|
88
|
+
/** Callback when the panel should close */
|
|
89
|
+
onClose?: () => void;
|
|
90
|
+
onBack?: () => void;
|
|
91
|
+
onNavigate?: (page: Page, subtab?: SettingsTab) => void;
|
|
92
|
+
onActionComplete?: (actionType: ActionType, data: ActionData) => void;
|
|
93
|
+
currentPage?: Page;
|
|
94
|
+
agentUrl?: string;
|
|
95
|
+
/** Custom starting questions (fetched per-user from backend) */
|
|
96
|
+
startingQuestions?: StartingQuestion[];
|
|
97
|
+
/** API endpoint to fetch starting questions */
|
|
98
|
+
startingQuestionsEndpoint?: string;
|
|
99
|
+
}
|
|
100
|
+
declare function ChatPanel({ isOpen, onClose, onBack, onNavigate, onActionComplete, currentPage, agentUrl, startingQuestions: startingQuestionsProp, startingQuestionsEndpoint }?: ChatPanelProps): react_jsx_runtime.JSX.Element;
|
|
101
|
+
/**
|
|
102
|
+
* PanelToggle - An arrow button on the right edge that toggles the side panel
|
|
103
|
+
* Shows left arrow when closed (click to open), right arrow when open (click to close)
|
|
104
|
+
* Uses fixed positioning to sit on the right edge of the viewport
|
|
105
|
+
*/
|
|
106
|
+
interface PanelToggleProps {
|
|
107
|
+
isOpen: boolean;
|
|
108
|
+
onClick: () => void;
|
|
109
|
+
className?: string;
|
|
110
|
+
}
|
|
111
|
+
declare function PanelToggle({ isOpen, onClick, className }: PanelToggleProps): react_jsx_runtime.JSX.Element;
|
|
112
|
+
/**
|
|
113
|
+
* ChatPanelWithToggle - Complete side panel with integrated toggle button
|
|
114
|
+
*
|
|
115
|
+
* This component renders a toggle arrow on the right side of the screen
|
|
116
|
+
* and a side panel that expands/collapses without overlaying existing content.
|
|
117
|
+
* When opened, it automatically adds padding to the body to push content left.
|
|
118
|
+
*
|
|
119
|
+
* Usage:
|
|
120
|
+
* ```tsx
|
|
121
|
+
* // Just drop it anywhere in your app - no layout changes needed
|
|
122
|
+
* function App() {
|
|
123
|
+
* return (
|
|
124
|
+
* <>
|
|
125
|
+
* <YourExistingApp />
|
|
126
|
+
* <ChatPanelWithToggle agentUrl="..." />
|
|
127
|
+
* </>
|
|
128
|
+
* );
|
|
129
|
+
* }
|
|
130
|
+
* ```
|
|
131
|
+
*/
|
|
132
|
+
interface ChatPanelWithToggleProps {
|
|
133
|
+
onNavigate?: (page: Page, subtab?: SettingsTab) => void;
|
|
134
|
+
onActionComplete?: (actionType: ActionType, data: ActionData) => void;
|
|
135
|
+
currentPage?: Page;
|
|
136
|
+
agentUrl?: string;
|
|
137
|
+
startingQuestions?: StartingQuestion[];
|
|
138
|
+
startingQuestionsEndpoint?: string;
|
|
139
|
+
/** Initial open state (default: false) */
|
|
140
|
+
defaultOpen?: boolean;
|
|
141
|
+
/** Controlled open state */
|
|
142
|
+
isOpen?: boolean;
|
|
143
|
+
/** Callback when panel open state changes */
|
|
144
|
+
onOpenChange?: (isOpen: boolean) => void;
|
|
145
|
+
}
|
|
146
|
+
declare function ChatPanelWithToggle({ onNavigate, onActionComplete, currentPage, agentUrl, startingQuestions, startingQuestionsEndpoint, defaultOpen, isOpen: controlledIsOpen, onOpenChange }: ChatPanelWithToggleProps): react_jsx_runtime.JSX.Element;
|
|
147
|
+
/**
|
|
148
|
+
* @deprecated Use ChatPanelWithToggle instead for the new side panel UX
|
|
149
|
+
*/
|
|
150
|
+
interface HelpButtonProps {
|
|
151
|
+
onClick: () => void;
|
|
152
|
+
className?: string;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* @deprecated Use ChatPanelWithToggle instead for the new side panel UX
|
|
156
|
+
*/
|
|
157
|
+
declare function HelpButton({ onClick, className }: HelpButtonProps): react_jsx_runtime.JSX.Element;
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* @kite-copilot/chat-panel - Programmatic API
|
|
161
|
+
*
|
|
162
|
+
* Industry-standard SDK pattern for embedding the Kite chat widget.
|
|
163
|
+
* No globals, explicit lifecycle control, tree-shakeable.
|
|
164
|
+
*
|
|
165
|
+
* Usage:
|
|
166
|
+
* ```ts
|
|
167
|
+
* import { createKiteChat } from '@kite-copilot/chat-panel';
|
|
168
|
+
* import '@kite-copilot/chat-panel/style.css';
|
|
169
|
+
*
|
|
170
|
+
* const chat = createKiteChat({
|
|
171
|
+
* userId: 'user-123',
|
|
172
|
+
* orgId: 'org-456',
|
|
173
|
+
* agentUrl: 'https://api.example.com',
|
|
174
|
+
* onNavigate: (page) => router.push(`/${page}`),
|
|
175
|
+
* });
|
|
176
|
+
*
|
|
177
|
+
* chat.mount('#chat-container');
|
|
178
|
+
* chat.open(); // Opens the side panel
|
|
179
|
+
* chat.close(); // Closes the side panel
|
|
180
|
+
* chat.setCurrentPage('settings');
|
|
181
|
+
* chat.unmount();
|
|
182
|
+
* ```
|
|
183
|
+
*/
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Configuration options for the Kite chat widget.
|
|
187
|
+
*/
|
|
188
|
+
interface KiteChatConfig {
|
|
189
|
+
/** Unique identifier for the current user */
|
|
190
|
+
userId: string;
|
|
191
|
+
/** Organization identifier */
|
|
192
|
+
orgId: string;
|
|
193
|
+
/** Backend agent API URL (defaults to http://localhost:5002) */
|
|
194
|
+
agentUrl?: string;
|
|
195
|
+
/** Current page context for the chat (e.g., 'dashboard', 'settings') */
|
|
196
|
+
currentPage?: string;
|
|
197
|
+
/** Theme mode */
|
|
198
|
+
theme?: 'light' | 'dark' | 'system';
|
|
199
|
+
/** Callback when the chat suggests navigation */
|
|
200
|
+
onNavigate?: (page: string, subtab?: string) => void;
|
|
201
|
+
/** Callback when an action is completed */
|
|
202
|
+
onActionComplete?: (actionType: ActionType, data: ActionData) => void;
|
|
203
|
+
/** Custom starting questions (fetched per-user from backend) */
|
|
204
|
+
startingQuestions?: StartingQuestion[];
|
|
205
|
+
/** API endpoint to fetch starting questions */
|
|
206
|
+
startingQuestionsEndpoint?: string;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Instance returned by createKiteChat with lifecycle control methods.
|
|
210
|
+
*/
|
|
211
|
+
interface KiteChatInstance {
|
|
212
|
+
/** Mount the chat widget into a container element */
|
|
213
|
+
mount: (container: string | HTMLElement) => void;
|
|
214
|
+
/** Unmount and clean up the chat widget */
|
|
215
|
+
unmount: () => void;
|
|
216
|
+
/** Open the side panel */
|
|
217
|
+
open: () => void;
|
|
218
|
+
/** Close the side panel */
|
|
219
|
+
close: () => void;
|
|
220
|
+
/** Toggle the side panel */
|
|
221
|
+
toggle: () => void;
|
|
222
|
+
/** Check if the panel is open */
|
|
223
|
+
isOpen: () => boolean;
|
|
224
|
+
/** Update the current page context */
|
|
225
|
+
setCurrentPage: (page: string) => void;
|
|
226
|
+
/** Update configuration (userId, orgId, callbacks, etc.) */
|
|
227
|
+
updateConfig: (config: Partial<KiteChatConfig>) => void;
|
|
228
|
+
/** Check if the widget is currently mounted */
|
|
229
|
+
isMounted: () => boolean;
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Create a new Kite chat widget instance.
|
|
233
|
+
*
|
|
234
|
+
* This is the primary API for embedding the chat widget.
|
|
235
|
+
* Returns an instance with explicit lifecycle control.
|
|
236
|
+
*
|
|
237
|
+
* @param config - Configuration options
|
|
238
|
+
* @returns KiteChatInstance with mount/unmount/update methods
|
|
239
|
+
*
|
|
240
|
+
* @example
|
|
241
|
+
* ```ts
|
|
242
|
+
* const chat = createKiteChat({
|
|
243
|
+
* userId: 'user-123',
|
|
244
|
+
* orgId: 'org-456',
|
|
245
|
+
* onNavigate: (page) => router.push(`/${page}`)
|
|
246
|
+
* });
|
|
247
|
+
*
|
|
248
|
+
* chat.mount('#chat-container');
|
|
249
|
+
* chat.open(); // Open the side panel
|
|
250
|
+
* ```
|
|
251
|
+
*/
|
|
252
|
+
declare function createKiteChat(config: KiteChatConfig): KiteChatInstance;
|
|
253
|
+
|
|
254
|
+
export { type ActionType as A, ChatPanel as C, HelpButton as H, type KiteChatConfig as K, type NavigationTarget as N, PanelToggle as P, type SettingsTab as S, type KiteChatInstance as a, ChatPanelWithToggle as b, createKiteChat as c, type ChatPanelProps as d, type ChatPanelWithToggleProps as e, type PanelToggleProps as f, type HelpButtonProps as g, type Page as h, type ActionData as i, type StartingQuestion as j };
|