acecoderz-chat-ui 1.0.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.
Files changed (62) hide show
  1. package/README.md +309 -0
  2. package/browser/index.ts +15 -0
  3. package/dist/adapters/react/ChatUI.d.ts +32 -0
  4. package/dist/adapters/react/ChatUI.d.ts.map +1 -0
  5. package/dist/adapters/react/ChatUI.js +170 -0
  6. package/dist/adapters/react/index.d.ts +5 -0
  7. package/dist/adapters/react/index.d.ts.map +1 -0
  8. package/dist/adapters/react/index.js +2 -0
  9. package/dist/adapters/react/useChat.d.ts +14 -0
  10. package/dist/adapters/react/useChat.d.ts.map +1 -0
  11. package/dist/adapters/react/useChat.js +64 -0
  12. package/dist/adapters/solid/createChat.d.ts +13 -0
  13. package/dist/adapters/solid/createChat.d.ts.map +1 -0
  14. package/dist/adapters/solid/createChat.js +34 -0
  15. package/dist/adapters/solid/index.d.ts +3 -0
  16. package/dist/adapters/solid/index.d.ts.map +1 -0
  17. package/dist/adapters/solid/index.js +1 -0
  18. package/dist/adapters/vanilla/index.d.ts +31 -0
  19. package/dist/adapters/vanilla/index.d.ts.map +1 -0
  20. package/dist/adapters/vanilla/index.js +346 -0
  21. package/dist/browser/Archive.zip +0 -0
  22. package/dist/browser/cdn-example.html +177 -0
  23. package/dist/browser/chatbot-ui.css +508 -0
  24. package/dist/browser/chatbot-ui.js +878 -0
  25. package/dist/browser/chatbot-ui.js.map +7 -0
  26. package/dist/browser/chatbot-ui.min.js +71 -0
  27. package/dist/browser/chatbot.html +100 -0
  28. package/dist/core/src/ChatEngine.d.ts +30 -0
  29. package/dist/core/src/ChatEngine.d.ts.map +1 -0
  30. package/dist/core/src/ChatEngine.js +357 -0
  31. package/dist/core/src/apiLogger.d.ts +47 -0
  32. package/dist/core/src/apiLogger.d.ts.map +1 -0
  33. package/dist/core/src/apiLogger.js +199 -0
  34. package/dist/core/src/index.d.ts +7 -0
  35. package/dist/core/src/index.d.ts.map +1 -0
  36. package/dist/core/src/index.js +3 -0
  37. package/dist/core/src/types.d.ts +62 -0
  38. package/dist/core/src/types.d.ts.map +1 -0
  39. package/dist/core/src/types.js +1 -0
  40. package/dist/core/src/urlWhitelist.d.ts +19 -0
  41. package/dist/core/src/urlWhitelist.d.ts.map +1 -0
  42. package/dist/core/src/urlWhitelist.js +66 -0
  43. package/dist/src/ChatUI.stories.d.ts +37 -0
  44. package/dist/src/ChatUI.stories.d.ts.map +1 -0
  45. package/dist/src/ChatUI.stories.js +65 -0
  46. package/dist/src/ChatUIThemes.stories.d.ts +28 -0
  47. package/dist/src/ChatUIThemes.stories.d.ts.map +1 -0
  48. package/dist/src/ChatUIThemes.stories.js +109 -0
  49. package/dist/src/ThemeProperties.stories.d.ts +92 -0
  50. package/dist/src/ThemeProperties.stories.d.ts.map +1 -0
  51. package/dist/src/ThemeProperties.stories.js +195 -0
  52. package/dist/src/UseChat.stories.d.ts +21 -0
  53. package/dist/src/UseChat.stories.d.ts.map +1 -0
  54. package/dist/src/UseChat.stories.js +66 -0
  55. package/dist/src/VanillaAdapter.stories.d.ts +39 -0
  56. package/dist/src/VanillaAdapter.stories.d.ts.map +1 -0
  57. package/dist/src/VanillaAdapter.stories.js +78 -0
  58. package/dist/src/index.d.ts +9 -0
  59. package/dist/src/index.d.ts.map +1 -0
  60. package/dist/src/index.js +8 -0
  61. package/package.json +117 -0
  62. package/styles/chat.css +508 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../core/src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,QAAQ,CAAC;IACtC,SAAS,EAAE,IAAI,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAChC;AAED,MAAM,WAAW,UAAU;IACzB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IACvC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACjC,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,uBAAuB,CAAC,EAAE,OAAO,CAAC;CACnC;AAED,MAAM,WAAW,SAAS;IAExB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;IAGrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IAGpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;IAGxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAC;IAGrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,cAAc,CAAC,EAAE,MAAM,CAAC;IAGxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC;IAGpB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAG3B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAG7B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,MAAM,aAAa,GAAG,gBAAgB,GAAG,aAAa,GAAG,eAAe,GAAG,OAAO,GAAG,SAAS,CAAC;AAErG,MAAM,MAAM,iBAAiB,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,KAAK,IAAI,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,19 @@
1
+ /**
2
+ * URL Whitelist Utility
3
+ * Checks if the current origin is whitelisted before making API calls
4
+ */
5
+ export interface WhitelistCheckResult {
6
+ isWhitelisted: boolean;
7
+ error?: string;
8
+ }
9
+ /**
10
+ * Check if the current origin is whitelisted
11
+ * @param apiUrl - The backend API URL
12
+ * @returns Promise with whitelist check result
13
+ */
14
+ export declare function checkUrlWhitelist(apiUrl: string): Promise<WhitelistCheckResult>;
15
+ /**
16
+ * Get a user-friendly error message for whitelist failures
17
+ */
18
+ export declare function getWhitelistErrorMessage(origin: string): string;
19
+ //# sourceMappingURL=urlWhitelist.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"urlWhitelist.d.ts","sourceRoot":"","sources":["../../../core/src/urlWhitelist.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,oBAAoB;IACnC,aAAa,EAAE,OAAO,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;GAIG;AACH,wBAAsB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC,CA0DrF;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAE/D"}
@@ -0,0 +1,66 @@
1
+ /**
2
+ * URL Whitelist Utility
3
+ * Checks if the current origin is whitelisted before making API calls
4
+ */
5
+ /**
6
+ * Check if the current origin is whitelisted
7
+ * @param apiUrl - The backend API URL
8
+ * @returns Promise with whitelist check result
9
+ */
10
+ export async function checkUrlWhitelist(apiUrl) {
11
+ try {
12
+ // Check if we're in a browser environment
13
+ if (typeof window === 'undefined' || !window.location) {
14
+ // Not in browser environment (e.g., Node.js, SSR), allow the request
15
+ return { isWhitelisted: true };
16
+ }
17
+ // Get current origin
18
+ const currentOrigin = window.location.origin;
19
+ if (!currentOrigin) {
20
+ // If we can't determine origin (e.g., file:// protocol), allow it
21
+ // This is useful for local development and testing
22
+ return { isWhitelisted: true };
23
+ }
24
+ // Call the public whitelist check endpoint
25
+ const checkUrl = `${apiUrl}/url-whitelist/check?url=${encodeURIComponent(currentOrigin)}`;
26
+ const response = await fetch(checkUrl, {
27
+ method: 'GET',
28
+ headers: {
29
+ 'Content-Type': 'application/json',
30
+ },
31
+ });
32
+ if (!response.ok) {
33
+ // If the endpoint doesn't exist or returns an error, allow the request
34
+ // This ensures backward compatibility
35
+ if (response.status === 404) {
36
+ return { isWhitelisted: true };
37
+ }
38
+ const errorData = await response.json().catch(() => ({ message: 'Unknown error' }));
39
+ return {
40
+ isWhitelisted: false,
41
+ error: errorData.error?.message || errorData.message || 'Failed to check URL whitelist',
42
+ };
43
+ }
44
+ const data = await response.json();
45
+ const result = data.data || data;
46
+ if (result.isWhitelisted) {
47
+ return { isWhitelisted: true };
48
+ }
49
+ return {
50
+ isWhitelisted: false,
51
+ error: `This chatbot is not authorized for ${currentOrigin}. Please contact the administrator.`,
52
+ };
53
+ }
54
+ catch (error) {
55
+ // If there's a network error or the endpoint is unavailable,
56
+ // allow the request (for backward compatibility and offline scenarios)
57
+ console.warn('URL whitelist check failed:', error);
58
+ return { isWhitelisted: true };
59
+ }
60
+ }
61
+ /**
62
+ * Get a user-friendly error message for whitelist failures
63
+ */
64
+ export function getWhitelistErrorMessage(origin) {
65
+ return `This chatbot is not authorized to work on ${origin}. Please contact the administrator to add this URL to the whitelist.`;
66
+ }
@@ -0,0 +1,37 @@
1
+ import type { StoryObj } from '@storybook/react';
2
+ declare const meta: {
3
+ title: string;
4
+ component: import("react").FC<import(".").ChatUIProps>;
5
+ parameters: {
6
+ layout: string;
7
+ };
8
+ tags: string[];
9
+ argTypes: {
10
+ placeholder: {
11
+ control: "text";
12
+ };
13
+ showTimestamp: {
14
+ control: "boolean";
15
+ };
16
+ showAvatar: {
17
+ control: "boolean";
18
+ };
19
+ disabled: {
20
+ control: "boolean";
21
+ };
22
+ maxHeight: {
23
+ control: "text";
24
+ };
25
+ theme: {
26
+ control: "object";
27
+ description: string;
28
+ };
29
+ };
30
+ };
31
+ export default meta;
32
+ type Story = StoryObj<typeof meta>;
33
+ export declare const Default: Story;
34
+ export declare const WithInitialGreeting: Story;
35
+ export declare const NoAvatars: Story;
36
+ export declare const NoTimestamps: Story;
37
+ //# sourceMappingURL=ChatUI.stories.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChatUI.stories.d.ts","sourceRoot":"","sources":["../../src/ChatUI.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAQ,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAGtD,QAAA,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkBqB,CAAA;AAE/B,eAAe,IAAI,CAAA;AACnB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAA;AAElC,eAAO,MAAM,OAAO,EAAE,KAarB,CAAA;AAED,eAAO,MAAM,mBAAmB,EAAE,KAcjC,CAAA;AAED,eAAO,MAAM,SAAS,EAAE,KAcvB,CAAA;AAED,eAAO,MAAM,YAAY,EAAE,KAc1B,CAAA"}
@@ -0,0 +1,65 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { ChatUI } from '../adapters/react/ChatUI';
3
+ const meta = {
4
+ title: 'React/ChatUI',
5
+ component: ChatUI,
6
+ parameters: {
7
+ layout: 'centered',
8
+ },
9
+ tags: ['autodocs'],
10
+ argTypes: {
11
+ placeholder: { control: 'text' },
12
+ showTimestamp: { control: 'boolean' },
13
+ showAvatar: { control: 'boolean' },
14
+ disabled: { control: 'boolean' },
15
+ maxHeight: { control: 'text' },
16
+ theme: {
17
+ control: 'object',
18
+ description: 'Theme configuration object. See Theme Properties story for all available options.',
19
+ },
20
+ },
21
+ };
22
+ export default meta;
23
+ export const Default = {
24
+ args: {
25
+ config: {
26
+ apiUrl: 'http://localhost:3000/api/chat',
27
+ },
28
+ },
29
+ decorators: [
30
+ (Story) => (_jsx("div", { style: { width: '600px', height: '600px' }, children: _jsx(Story, {}) })),
31
+ ],
32
+ };
33
+ export const WithInitialGreeting = {
34
+ args: {
35
+ config: {
36
+ apiUrl: 'http://localhost:3000/api/chat',
37
+ },
38
+ initialGreeting: 'Hello! How can I help you today?',
39
+ },
40
+ decorators: [
41
+ (Story) => (_jsx("div", { style: { width: '600px', height: '600px' }, children: _jsx(Story, {}) })),
42
+ ],
43
+ };
44
+ export const NoAvatars = {
45
+ args: {
46
+ config: {
47
+ apiUrl: 'http://localhost:3000/api/chat',
48
+ },
49
+ showAvatar: false,
50
+ },
51
+ decorators: [
52
+ (Story) => (_jsx("div", { style: { width: '600px', height: '600px' }, children: _jsx(Story, {}) })),
53
+ ],
54
+ };
55
+ export const NoTimestamps = {
56
+ args: {
57
+ config: {
58
+ apiUrl: 'http://localhost:3000/api/chat',
59
+ },
60
+ showTimestamp: false,
61
+ },
62
+ decorators: [
63
+ (Story) => (_jsx("div", { style: { width: '600px', height: '600px' }, children: _jsx(Story, {}) })),
64
+ ],
65
+ };
@@ -0,0 +1,28 @@
1
+ import type { StoryObj } from '@storybook/react';
2
+ declare const meta: {
3
+ title: string;
4
+ component: import("react").FC<import(".").ChatUIProps>;
5
+ parameters: {
6
+ layout: string;
7
+ docs: {
8
+ description: {
9
+ component: string;
10
+ };
11
+ };
12
+ };
13
+ tags: string[];
14
+ argTypes: {
15
+ theme: {
16
+ control: "object";
17
+ description: string;
18
+ };
19
+ };
20
+ };
21
+ export default meta;
22
+ type Story = StoryObj<typeof meta>;
23
+ export declare const Default: Story;
24
+ export declare const Blue: Story;
25
+ export declare const Green: Story;
26
+ export declare const Purple: Story;
27
+ export declare const Dark: Story;
28
+ //# sourceMappingURL=ChatUIThemes.stories.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChatUIThemes.stories.d.ts","sourceRoot":"","sources":["../../src/ChatUIThemes.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAQ,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAItD,QAAA,MAAM,IAAI;;;;;;;;;;;;;;;;;;CAkBqB,CAAA;AAE/B,eAAe,IAAI,CAAA;AACnB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAA;AA8BlC,eAAO,MAAM,OAAO,EAAE,KAerB,CAAA;AAED,eAAO,MAAM,IAAI,EAAE,KAelB,CAAA;AAED,eAAO,MAAM,KAAK,EAAE,KAenB,CAAA;AAED,eAAO,MAAM,MAAM,EAAE,KAepB,CAAA;AAED,eAAO,MAAM,IAAI,EAAE,KAelB,CAAA"}
@@ -0,0 +1,109 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { ChatUI } from '../adapters/react/ChatUI';
3
+ const meta = {
4
+ title: 'React/ChatUI/Themes',
5
+ component: ChatUI,
6
+ parameters: {
7
+ layout: 'centered',
8
+ docs: {
9
+ description: {
10
+ component: 'Pre-configured theme examples. See Theme Properties story for all available customization options.',
11
+ },
12
+ },
13
+ },
14
+ tags: ['autodocs'],
15
+ argTypes: {
16
+ theme: {
17
+ control: 'object',
18
+ description: 'Theme object. See Theme Properties story for complete reference.',
19
+ },
20
+ },
21
+ };
22
+ export default meta;
23
+ const themes = {
24
+ default: {},
25
+ blue: {
26
+ primaryColor: '#3b82f6',
27
+ userMessageColor: '#3b82f6',
28
+ assistantMessageColor: '#dbeafe',
29
+ },
30
+ green: {
31
+ primaryColor: '#10b981',
32
+ userMessageColor: '#10b981',
33
+ assistantMessageColor: '#d1fae5',
34
+ },
35
+ purple: {
36
+ primaryColor: '#8b5cf6',
37
+ userMessageColor: '#8b5cf6',
38
+ assistantMessageColor: '#ede9fe',
39
+ },
40
+ dark: {
41
+ primaryColor: '#6366f1',
42
+ backgroundColor: '#1e293b',
43
+ textColor: '#f1f5f9',
44
+ userMessageColor: '#6366f1',
45
+ assistantMessageColor: '#334155',
46
+ inputBackgroundColor: '#334155',
47
+ inputTextColor: '#f1f5f9',
48
+ },
49
+ };
50
+ export const Default = {
51
+ args: {
52
+ config: {
53
+ apiUrl: 'http://localhost:3000/api/chat',
54
+ },
55
+ theme: themes.default,
56
+ initialGreeting: 'This is the default theme',
57
+ },
58
+ decorators: [
59
+ (Story) => (_jsx("div", { style: { width: '600px', height: '600px' }, children: _jsx(Story, {}) })),
60
+ ],
61
+ };
62
+ export const Blue = {
63
+ args: {
64
+ config: {
65
+ apiUrl: 'http://localhost:3000/api/chat',
66
+ },
67
+ theme: themes.blue,
68
+ initialGreeting: 'This is the blue theme',
69
+ },
70
+ decorators: [
71
+ (Story) => (_jsx("div", { style: { width: '600px', height: '600px' }, children: _jsx(Story, {}) })),
72
+ ],
73
+ };
74
+ export const Green = {
75
+ args: {
76
+ config: {
77
+ apiUrl: 'http://localhost:3000/api/chat',
78
+ },
79
+ theme: themes.green,
80
+ initialGreeting: 'This is the green theme',
81
+ },
82
+ decorators: [
83
+ (Story) => (_jsx("div", { style: { width: '600px', height: '600px' }, children: _jsx(Story, {}) })),
84
+ ],
85
+ };
86
+ export const Purple = {
87
+ args: {
88
+ config: {
89
+ apiUrl: 'http://localhost:3000/api/chat',
90
+ },
91
+ theme: themes.purple,
92
+ initialGreeting: 'This is the purple theme',
93
+ },
94
+ decorators: [
95
+ (Story) => (_jsx("div", { style: { width: '600px', height: '600px' }, children: _jsx(Story, {}) })),
96
+ ],
97
+ };
98
+ export const Dark = {
99
+ args: {
100
+ config: {
101
+ apiUrl: 'http://localhost:3000/api/chat',
102
+ },
103
+ theme: themes.dark,
104
+ initialGreeting: 'This is the dark theme',
105
+ },
106
+ decorators: [
107
+ (Story) => (_jsx("div", { style: { width: '600px', height: '600px' }, children: _jsx(Story, {}) })),
108
+ ],
109
+ };
@@ -0,0 +1,92 @@
1
+ import type { StoryObj } from '@storybook/react';
2
+ /**
3
+ * # ChatTheme Properties Reference
4
+ *
5
+ * All available CSS custom properties that can be customized via the `theme` prop.
6
+ * These properties map to CSS variables used throughout the chat UI.
7
+ *
8
+ * ## Colors
9
+ * - `primaryColor` → `--chat-primary-color` - Primary accent color
10
+ * - `secondaryColor` → `--chat-secondary-color` - Secondary color
11
+ * - `backgroundColor` → `--chat-background-color` - Main background color
12
+ * - `textColor` → `--chat-text-color` - Main text color
13
+ * - `userMessageColor` → `--chat-user-message-color` - User message background color
14
+ * - `assistantMessageColor` → `--chat-assistant-message-color` - Assistant message background color
15
+ * - `inputBackgroundColor` → `--chat-input-background-color` - Input field background
16
+ * - `inputTextColor` → `--chat-input-text-color` - Input text color
17
+ * - `errorBackgroundColor` → `--chat-error-background-color` - Error message background
18
+ * - `errorTextColor` → `--chat-error-text-color` - Error text color
19
+ * - `borderColor` → `--chat-border-color` - Border color
20
+ *
21
+ * ## Typography
22
+ * - `fontFamily` → `--chat-font-family` - Font family (e.g., 'Arial, sans-serif')
23
+ * - `fontSize` → `--chat-font-size` - Base font size (e.g., '1rem', '16px')
24
+ * - `fontWeight` → `--chat-font-weight` - Font weight (e.g., '400', 'bold')
25
+ * - `lineHeight` → `--chat-line-height` - Line height (e.g., '1.5', '1.6')
26
+ *
27
+ * ## Spacing
28
+ * - `padding` → `--chat-padding` - Container padding
29
+ * - `messageGap` → `--chat-message-gap` - Gap between messages
30
+ * - `inputPadding` → `--chat-input-padding` - Input field padding
31
+ * - `messagePadding` → `--chat-message-padding` - Message bubble padding
32
+ *
33
+ * ## Borders & Radius
34
+ * - `borderRadius` → `--chat-border-radius` - General border radius
35
+ * - `messageBorderRadius` → `--chat-message-border-radius` - Message bubble border radius
36
+ * - `inputBorderRadius` → `--chat-input-border-radius` - Input field border radius
37
+ * - `borderWidth` → `--chat-border-width` - Border width
38
+ *
39
+ * ## Shadows
40
+ * - `boxShadow` → `--chat-box-shadow` - General box shadow
41
+ * - `messageBoxShadow` → `--chat-message-box-shadow` - Message bubble shadow
42
+ * - `inputBoxShadow` → `--chat-input-box-shadow` - Input field shadow
43
+ *
44
+ * ## Sizing
45
+ * - `maxHeight` → `--chat-max-height` - Maximum container height
46
+ * - `maxWidth` → `--chat-max-width` - Maximum container width
47
+ * - `messageMaxWidth` → `--chat-message-max-width` - Maximum message width
48
+ * - `avatarSize` → `--chat-avatar-size` - Avatar size
49
+ *
50
+ * ## Transitions & Animations
51
+ * - `transitionDuration` → `--chat-transition-duration` - Transition duration
52
+ * - `animationDuration` → `--chat-animation-duration` - Animation duration
53
+ *
54
+ * ## Scrollbar
55
+ * - `scrollbarWidth` → `--chat-scrollbar-width` - Scrollbar width
56
+ * - `scrollbarColor` → `--chat-scrollbar-color` - Scrollbar thumb color
57
+ * - `scrollbarTrackColor` → `--chat-scrollbar-track-color` - Scrollbar track color
58
+ *
59
+ * ## Advanced
60
+ * - `customCSS` → Injected as raw CSS string for advanced customization
61
+ */
62
+ declare const meta: {
63
+ title: string;
64
+ component: import("react").FC<import(".").ChatUIProps>;
65
+ parameters: {
66
+ layout: string;
67
+ docs: {
68
+ description: {
69
+ component: string;
70
+ };
71
+ };
72
+ };
73
+ tags: string[];
74
+ argTypes: {
75
+ theme: {
76
+ description: string;
77
+ control: "object";
78
+ table: {
79
+ type: {
80
+ summary: string;
81
+ };
82
+ };
83
+ };
84
+ };
85
+ };
86
+ export default meta;
87
+ type Story = StoryObj<typeof meta>;
88
+ export declare const AllProperties: Story;
89
+ export declare const MinimalTheme: Story;
90
+ export declare const CustomTypography: Story;
91
+ export declare const CustomSpacing: Story;
92
+ //# sourceMappingURL=ThemeProperties.stories.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ThemeProperties.stories.d.ts","sourceRoot":"","sources":["../../src/ThemeProperties.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAQ,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAGtD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2DG;AAEH,QAAA,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;CAqBqB,CAAA;AAE/B,eAAe,IAAI,CAAA;AACnB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAA;AAGlC,eAAO,MAAM,aAAa,EAAE,KAkE3B,CAAA;AAGD,eAAO,MAAM,YAAY,EAAE,KAmB1B,CAAA;AAGD,eAAO,MAAM,gBAAgB,EAAE,KAoB9B,CAAA;AAGD,eAAO,MAAM,aAAa,EAAE,KAoB3B,CAAA"}
@@ -0,0 +1,195 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { ChatUI } from '../adapters/react/ChatUI';
3
+ /**
4
+ * # ChatTheme Properties Reference
5
+ *
6
+ * All available CSS custom properties that can be customized via the `theme` prop.
7
+ * These properties map to CSS variables used throughout the chat UI.
8
+ *
9
+ * ## Colors
10
+ * - `primaryColor` → `--chat-primary-color` - Primary accent color
11
+ * - `secondaryColor` → `--chat-secondary-color` - Secondary color
12
+ * - `backgroundColor` → `--chat-background-color` - Main background color
13
+ * - `textColor` → `--chat-text-color` - Main text color
14
+ * - `userMessageColor` → `--chat-user-message-color` - User message background color
15
+ * - `assistantMessageColor` → `--chat-assistant-message-color` - Assistant message background color
16
+ * - `inputBackgroundColor` → `--chat-input-background-color` - Input field background
17
+ * - `inputTextColor` → `--chat-input-text-color` - Input text color
18
+ * - `errorBackgroundColor` → `--chat-error-background-color` - Error message background
19
+ * - `errorTextColor` → `--chat-error-text-color` - Error text color
20
+ * - `borderColor` → `--chat-border-color` - Border color
21
+ *
22
+ * ## Typography
23
+ * - `fontFamily` → `--chat-font-family` - Font family (e.g., 'Arial, sans-serif')
24
+ * - `fontSize` → `--chat-font-size` - Base font size (e.g., '1rem', '16px')
25
+ * - `fontWeight` → `--chat-font-weight` - Font weight (e.g., '400', 'bold')
26
+ * - `lineHeight` → `--chat-line-height` - Line height (e.g., '1.5', '1.6')
27
+ *
28
+ * ## Spacing
29
+ * - `padding` → `--chat-padding` - Container padding
30
+ * - `messageGap` → `--chat-message-gap` - Gap between messages
31
+ * - `inputPadding` → `--chat-input-padding` - Input field padding
32
+ * - `messagePadding` → `--chat-message-padding` - Message bubble padding
33
+ *
34
+ * ## Borders & Radius
35
+ * - `borderRadius` → `--chat-border-radius` - General border radius
36
+ * - `messageBorderRadius` → `--chat-message-border-radius` - Message bubble border radius
37
+ * - `inputBorderRadius` → `--chat-input-border-radius` - Input field border radius
38
+ * - `borderWidth` → `--chat-border-width` - Border width
39
+ *
40
+ * ## Shadows
41
+ * - `boxShadow` → `--chat-box-shadow` - General box shadow
42
+ * - `messageBoxShadow` → `--chat-message-box-shadow` - Message bubble shadow
43
+ * - `inputBoxShadow` → `--chat-input-box-shadow` - Input field shadow
44
+ *
45
+ * ## Sizing
46
+ * - `maxHeight` → `--chat-max-height` - Maximum container height
47
+ * - `maxWidth` → `--chat-max-width` - Maximum container width
48
+ * - `messageMaxWidth` → `--chat-message-max-width` - Maximum message width
49
+ * - `avatarSize` → `--chat-avatar-size` - Avatar size
50
+ *
51
+ * ## Transitions & Animations
52
+ * - `transitionDuration` → `--chat-transition-duration` - Transition duration
53
+ * - `animationDuration` → `--chat-animation-duration` - Animation duration
54
+ *
55
+ * ## Scrollbar
56
+ * - `scrollbarWidth` → `--chat-scrollbar-width` - Scrollbar width
57
+ * - `scrollbarColor` → `--chat-scrollbar-color` - Scrollbar thumb color
58
+ * - `scrollbarTrackColor` → `--chat-scrollbar-track-color` - Scrollbar track color
59
+ *
60
+ * ## Advanced
61
+ * - `customCSS` → Injected as raw CSS string for advanced customization
62
+ */
63
+ const meta = {
64
+ title: 'React/ChatUI/Theme Properties',
65
+ component: ChatUI,
66
+ parameters: {
67
+ layout: 'centered',
68
+ docs: {
69
+ description: {
70
+ component: 'Complete reference of all available theme properties and their corresponding CSS variables.',
71
+ },
72
+ },
73
+ },
74
+ tags: ['autodocs'],
75
+ argTypes: {
76
+ theme: {
77
+ description: 'Theme object with CSS custom properties',
78
+ control: 'object',
79
+ table: {
80
+ type: { summary: 'ChatTheme' },
81
+ },
82
+ },
83
+ },
84
+ };
85
+ export default meta;
86
+ // Example showing all theme properties
87
+ export const AllProperties = {
88
+ args: {
89
+ config: {
90
+ apiUrl: 'http://localhost:3000/api/chat',
91
+ },
92
+ theme: {
93
+ // Colors
94
+ primaryColor: '#6366f1',
95
+ secondaryColor: '#64748b',
96
+ backgroundColor: '#ffffff',
97
+ textColor: '#1e293b',
98
+ userMessageColor: '#6366f1',
99
+ assistantMessageColor: '#f1f5f9',
100
+ inputBackgroundColor: '#f8fafc',
101
+ inputTextColor: '#1e293b',
102
+ errorBackgroundColor: '#fee2e2',
103
+ errorTextColor: '#dc2626',
104
+ borderColor: '#e2e8f0',
105
+ // Typography
106
+ fontFamily: 'system-ui, -apple-system, sans-serif',
107
+ fontSize: '1rem',
108
+ fontWeight: '400',
109
+ lineHeight: '1.5',
110
+ // Spacing
111
+ padding: '1rem',
112
+ messageGap: '1rem',
113
+ inputPadding: '1rem',
114
+ messagePadding: '0.75rem 1rem',
115
+ // Borders & Radius
116
+ borderRadius: '0.5rem',
117
+ messageBorderRadius: '0.75rem',
118
+ inputBorderRadius: '0.5rem',
119
+ borderWidth: '1px',
120
+ // Shadows
121
+ boxShadow: '0 1px 3px rgba(0, 0, 0, 0.1)',
122
+ messageBoxShadow: '0 1px 2px rgba(0, 0, 0, 0.05)',
123
+ inputBoxShadow: '0 1px 2px rgba(0, 0, 0, 0.05)',
124
+ // Sizing
125
+ maxHeight: '600px',
126
+ maxWidth: '100%',
127
+ messageMaxWidth: '80%',
128
+ avatarSize: '2rem',
129
+ // Transitions & Animations
130
+ transitionDuration: '200ms',
131
+ animationDuration: '300ms',
132
+ // Scrollbar
133
+ scrollbarWidth: '8px',
134
+ scrollbarColor: '#cbd5e1',
135
+ scrollbarTrackColor: '#f1f5f9',
136
+ },
137
+ initialGreeting: 'This example shows all available theme properties. Check the controls to customize!',
138
+ },
139
+ decorators: [
140
+ (Story) => (_jsx("div", { style: { width: '600px', height: '600px' }, children: _jsx(Story, {}) })),
141
+ ],
142
+ };
143
+ // Minimal theme example
144
+ export const MinimalTheme = {
145
+ args: {
146
+ config: {
147
+ apiUrl: 'http://localhost:3000/api/chat',
148
+ },
149
+ theme: {
150
+ primaryColor: '#3b82f6',
151
+ userMessageColor: '#3b82f6',
152
+ assistantMessageColor: '#f1f5f9',
153
+ },
154
+ initialGreeting: 'Minimal theme with just colors',
155
+ },
156
+ decorators: [
157
+ (Story) => (_jsx("div", { style: { width: '600px', height: '600px' }, children: _jsx(Story, {}) })),
158
+ ],
159
+ };
160
+ // Custom typography example
161
+ export const CustomTypography = {
162
+ args: {
163
+ config: {
164
+ apiUrl: 'http://localhost:3000/api/chat',
165
+ },
166
+ theme: {
167
+ fontFamily: '"Georgia", serif',
168
+ fontSize: '1.125rem',
169
+ lineHeight: '1.8',
170
+ fontWeight: '400',
171
+ },
172
+ initialGreeting: 'Custom typography with serif font and larger size',
173
+ },
174
+ decorators: [
175
+ (Story) => (_jsx("div", { style: { width: '600px', height: '600px' }, children: _jsx(Story, {}) })),
176
+ ],
177
+ };
178
+ // Custom spacing example
179
+ export const CustomSpacing = {
180
+ args: {
181
+ config: {
182
+ apiUrl: 'http://localhost:3000/api/chat',
183
+ },
184
+ theme: {
185
+ padding: '2rem',
186
+ messageGap: '1.5rem',
187
+ messagePadding: '1rem 1.5rem',
188
+ inputPadding: '1.25rem',
189
+ },
190
+ initialGreeting: 'Custom spacing with more generous padding',
191
+ },
192
+ decorators: [
193
+ (Story) => (_jsx("div", { style: { width: '600px', height: '600px' }, children: _jsx(Story, {}) })),
194
+ ],
195
+ };
@@ -0,0 +1,21 @@
1
+ import type { StoryObj } from '@storybook/react';
2
+ declare function UseChatDemo({ apiUrl }: {
3
+ apiUrl: string;
4
+ }): import("react/jsx-runtime").JSX.Element;
5
+ declare const meta: {
6
+ title: string;
7
+ component: typeof UseChatDemo;
8
+ parameters: {
9
+ layout: string;
10
+ };
11
+ tags: string[];
12
+ argTypes: {
13
+ apiUrl: {
14
+ control: "text";
15
+ };
16
+ };
17
+ };
18
+ export default meta;
19
+ type Story = StoryObj<typeof meta>;
20
+ export declare const Default: Story;
21
+ //# sourceMappingURL=UseChat.stories.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UseChat.stories.d.ts","sourceRoot":"","sources":["../../src/UseChat.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAQ,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAItD,iBAAS,WAAW,CAAC,EAAE,MAAM,EAAE,EAAE;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,2CAsGlD;AAED,QAAA,MAAM,IAAI;;;;;;;;;;;;CAU0B,CAAA;AAEpC,eAAe,IAAI,CAAA;AACnB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAA;AAElC,eAAO,MAAM,OAAO,EAAE,KAIrB,CAAA"}