@chainai/react 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.
- package/README.md +227 -0
- package/dist/components/ActionPrompt.d.ts +22 -0
- package/dist/components/ActionPrompt.js +130 -0
- package/dist/components/ChainAI.d.ts +19 -0
- package/dist/components/ChainAI.js +89 -0
- package/dist/components/ChainAIWidget.d.ts +86 -0
- package/dist/components/ChainAIWidget.js +243 -0
- package/dist/components/ChatHeader.d.ts +11 -0
- package/dist/components/ChatHeader.js +20 -0
- package/dist/components/ChatInput.d.ts +12 -0
- package/dist/components/ChatInput.js +65 -0
- package/dist/components/ChatMessage.d.ts +11 -0
- package/dist/components/ChatMessage.js +20 -0
- package/dist/context/ChainAIProvider.d.ts +19 -0
- package/dist/context/ChainAIProvider.js +95 -0
- package/dist/hooks/useChat.d.ts +12 -0
- package/dist/hooks/useChat.js +80 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.js +34 -0
- package/dist/styles/themes.d.ts +31 -0
- package/dist/styles/themes.js +49 -0
- package/package.json +67 -0
- package/styles/default.css +156 -0
- package/styles/widget.css +531 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @chain-ai/react - React components for Chain AI
|
|
4
|
+
*
|
|
5
|
+
* Embeddable blockchain AI assistant components
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.lightTheme = exports.darkTheme = exports.defaultTheme = exports.useChat = exports.useChainAI = exports.ChainAIProvider = exports.ActionPrompt = exports.ChatHeader = exports.ChatInput = exports.ChatMessage = exports.ChainAIWidget = exports.ChainAI = void 0;
|
|
9
|
+
// Main component exports
|
|
10
|
+
var ChainAI_1 = require("./components/ChainAI");
|
|
11
|
+
Object.defineProperty(exports, "ChainAI", { enumerable: true, get: function () { return ChainAI_1.ChainAI; } });
|
|
12
|
+
var ChainAIWidget_1 = require("./components/ChainAIWidget");
|
|
13
|
+
Object.defineProperty(exports, "ChainAIWidget", { enumerable: true, get: function () { return ChainAIWidget_1.ChainAIWidget; } });
|
|
14
|
+
// Individual component exports
|
|
15
|
+
var ChatMessage_1 = require("./components/ChatMessage");
|
|
16
|
+
Object.defineProperty(exports, "ChatMessage", { enumerable: true, get: function () { return ChatMessage_1.ChatMessage; } });
|
|
17
|
+
var ChatInput_1 = require("./components/ChatInput");
|
|
18
|
+
Object.defineProperty(exports, "ChatInput", { enumerable: true, get: function () { return ChatInput_1.ChatInput; } });
|
|
19
|
+
var ChatHeader_1 = require("./components/ChatHeader");
|
|
20
|
+
Object.defineProperty(exports, "ChatHeader", { enumerable: true, get: function () { return ChatHeader_1.ChatHeader; } });
|
|
21
|
+
var ActionPrompt_1 = require("./components/ActionPrompt");
|
|
22
|
+
Object.defineProperty(exports, "ActionPrompt", { enumerable: true, get: function () { return ActionPrompt_1.ActionPrompt; } });
|
|
23
|
+
// Context/Provider exports
|
|
24
|
+
var ChainAIProvider_1 = require("./context/ChainAIProvider");
|
|
25
|
+
Object.defineProperty(exports, "ChainAIProvider", { enumerable: true, get: function () { return ChainAIProvider_1.ChainAIProvider; } });
|
|
26
|
+
Object.defineProperty(exports, "useChainAI", { enumerable: true, get: function () { return ChainAIProvider_1.useChainAI; } });
|
|
27
|
+
// Hook exports
|
|
28
|
+
var useChat_1 = require("./hooks/useChat");
|
|
29
|
+
Object.defineProperty(exports, "useChat", { enumerable: true, get: function () { return useChat_1.useChat; } });
|
|
30
|
+
// Theme exports
|
|
31
|
+
var themes_1 = require("./styles/themes");
|
|
32
|
+
Object.defineProperty(exports, "defaultTheme", { enumerable: true, get: function () { return themes_1.defaultTheme; } });
|
|
33
|
+
Object.defineProperty(exports, "darkTheme", { enumerable: true, get: function () { return themes_1.darkTheme; } });
|
|
34
|
+
Object.defineProperty(exports, "lightTheme", { enumerable: true, get: function () { return themes_1.lightTheme; } });
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Theme system for Chain AI React components
|
|
3
|
+
*/
|
|
4
|
+
export interface Theme {
|
|
5
|
+
colors: {
|
|
6
|
+
primary: string;
|
|
7
|
+
primaryText: string;
|
|
8
|
+
background: string;
|
|
9
|
+
text: string;
|
|
10
|
+
border: string;
|
|
11
|
+
userMessage: string;
|
|
12
|
+
userMessageText: string;
|
|
13
|
+
assistantMessage: string;
|
|
14
|
+
assistantMessageText: string;
|
|
15
|
+
inputBackground: string;
|
|
16
|
+
headerBackground: string;
|
|
17
|
+
headerText: string;
|
|
18
|
+
};
|
|
19
|
+
fonts: {
|
|
20
|
+
body: string;
|
|
21
|
+
heading: string;
|
|
22
|
+
};
|
|
23
|
+
spacing: {
|
|
24
|
+
small: string;
|
|
25
|
+
medium: string;
|
|
26
|
+
large: string;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
export declare const defaultTheme: Theme;
|
|
30
|
+
export declare const darkTheme: Theme;
|
|
31
|
+
export declare const lightTheme: Theme;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Theme system for Chain AI React components
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.lightTheme = exports.darkTheme = exports.defaultTheme = void 0;
|
|
7
|
+
exports.defaultTheme = {
|
|
8
|
+
colors: {
|
|
9
|
+
primary: '#3b82f6',
|
|
10
|
+
primaryText: '#ffffff',
|
|
11
|
+
background: '#ffffff',
|
|
12
|
+
text: '#1f2937',
|
|
13
|
+
border: '#e5e7eb',
|
|
14
|
+
userMessage: '#3b82f6',
|
|
15
|
+
userMessageText: '#ffffff',
|
|
16
|
+
assistantMessage: '#f3f4f6',
|
|
17
|
+
assistantMessageText: '#1f2937',
|
|
18
|
+
inputBackground: '#ffffff',
|
|
19
|
+
headerBackground: '#f9fafb',
|
|
20
|
+
headerText: '#1f2937',
|
|
21
|
+
},
|
|
22
|
+
fonts: {
|
|
23
|
+
body: 'system-ui, -apple-system, sans-serif',
|
|
24
|
+
heading: 'system-ui, -apple-system, sans-serif',
|
|
25
|
+
},
|
|
26
|
+
spacing: {
|
|
27
|
+
small: '8px',
|
|
28
|
+
medium: '16px',
|
|
29
|
+
large: '24px',
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
exports.darkTheme = {
|
|
33
|
+
...exports.defaultTheme,
|
|
34
|
+
colors: {
|
|
35
|
+
primary: '#3b82f6',
|
|
36
|
+
primaryText: '#ffffff',
|
|
37
|
+
background: '#1f2937',
|
|
38
|
+
text: '#f9fafb',
|
|
39
|
+
border: '#374151',
|
|
40
|
+
userMessage: '#3b82f6',
|
|
41
|
+
userMessageText: '#ffffff',
|
|
42
|
+
assistantMessage: '#374151',
|
|
43
|
+
assistantMessageText: '#f9fafb',
|
|
44
|
+
inputBackground: '#374151',
|
|
45
|
+
headerBackground: '#111827',
|
|
46
|
+
headerText: '#f9fafb',
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
exports.lightTheme = exports.defaultTheme;
|
package/package.json
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@chainai/react",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "React components for Chain AI - Embeddable blockchain AI assistant widget",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.esm.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"sideEffects": [
|
|
9
|
+
"**/*.css"
|
|
10
|
+
],
|
|
11
|
+
"files": [
|
|
12
|
+
"dist",
|
|
13
|
+
"styles"
|
|
14
|
+
],
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"import": "./dist/index.js",
|
|
19
|
+
"require": "./dist/index.js"
|
|
20
|
+
},
|
|
21
|
+
"./styles/widget.css": "./styles/widget.css",
|
|
22
|
+
"./styles/default.css": "./styles/default.css"
|
|
23
|
+
},
|
|
24
|
+
"scripts": {
|
|
25
|
+
"build": "tsc && npm run copy-styles",
|
|
26
|
+
"copy-styles": "mkdir -p styles && cp src/styles/*.css styles/",
|
|
27
|
+
"dev": "tsc --watch",
|
|
28
|
+
"test": "jest",
|
|
29
|
+
"lint": "eslint src --ext .ts,.tsx",
|
|
30
|
+
"type-check": "tsc --noEmit",
|
|
31
|
+
"prepublishOnly": "npm run build"
|
|
32
|
+
},
|
|
33
|
+
"keywords": [
|
|
34
|
+
"blockchain",
|
|
35
|
+
"ai",
|
|
36
|
+
"react",
|
|
37
|
+
"chat",
|
|
38
|
+
"widget",
|
|
39
|
+
"ui",
|
|
40
|
+
"chain-ai",
|
|
41
|
+
"crypto",
|
|
42
|
+
"web3",
|
|
43
|
+
"chatbot"
|
|
44
|
+
],
|
|
45
|
+
"author": "Chain AI",
|
|
46
|
+
"license": "MIT",
|
|
47
|
+
"dependencies": {
|
|
48
|
+
"@chainai/core": "^1.0.0"
|
|
49
|
+
},
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"@types/react": "^18.3.3",
|
|
52
|
+
"@types/react-dom": "^18.3.0",
|
|
53
|
+
"typescript": "^5.4.5"
|
|
54
|
+
},
|
|
55
|
+
"peerDependencies": {
|
|
56
|
+
"react": "^18.0.0 || ^19.0.0",
|
|
57
|
+
"react-dom": "^18.0.0 || ^19.0.0"
|
|
58
|
+
},
|
|
59
|
+
"repository": {
|
|
60
|
+
"type": "git",
|
|
61
|
+
"url": "https://github.com/chain-ai/npm-packages.git"
|
|
62
|
+
},
|
|
63
|
+
"homepage": "https://github.com/chain-ai/npm-packages#readme",
|
|
64
|
+
"bugs": {
|
|
65
|
+
"url": "https://github.com/chain-ai/npm-packages/issues"
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/* Chain AI Default Styles */
|
|
2
|
+
|
|
3
|
+
.chain-ai-container {
|
|
4
|
+
display: flex;
|
|
5
|
+
flex-direction: column;
|
|
6
|
+
border: 1px solid #e5e7eb;
|
|
7
|
+
border-radius: 8px;
|
|
8
|
+
overflow: hidden;
|
|
9
|
+
font-family: system-ui, -apple-system, sans-serif;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.chain-ai-header {
|
|
13
|
+
display: flex;
|
|
14
|
+
align-items: center;
|
|
15
|
+
justify-content: space-between;
|
|
16
|
+
padding: 16px;
|
|
17
|
+
border-bottom: 1px solid;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.chain-ai-header-title {
|
|
21
|
+
margin: 0;
|
|
22
|
+
font-size: 18px;
|
|
23
|
+
font-weight: 600;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.chain-ai-header-close {
|
|
27
|
+
background: none;
|
|
28
|
+
border: none;
|
|
29
|
+
font-size: 24px;
|
|
30
|
+
cursor: pointer;
|
|
31
|
+
padding: 0;
|
|
32
|
+
width: 32px;
|
|
33
|
+
height: 32px;
|
|
34
|
+
display: flex;
|
|
35
|
+
align-items: center;
|
|
36
|
+
justify-content: center;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.chain-ai-messages {
|
|
40
|
+
flex: 1;
|
|
41
|
+
overflow-y: auto;
|
|
42
|
+
padding: 16px;
|
|
43
|
+
display: flex;
|
|
44
|
+
flex-direction: column;
|
|
45
|
+
gap: 12px;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.chain-ai-welcome {
|
|
49
|
+
text-align: center;
|
|
50
|
+
padding: 48px 16px;
|
|
51
|
+
color: #6b7280;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.chain-ai-welcome h2 {
|
|
55
|
+
margin: 0 0 8px 0;
|
|
56
|
+
font-size: 24px;
|
|
57
|
+
font-weight: 600;
|
|
58
|
+
color: inherit;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.chain-ai-welcome p {
|
|
62
|
+
margin: 0;
|
|
63
|
+
font-size: 16px;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.chain-ai-message {
|
|
67
|
+
max-width: 80%;
|
|
68
|
+
padding: 12px 16px;
|
|
69
|
+
border-radius: 8px;
|
|
70
|
+
position: relative;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.chain-ai-message-user {
|
|
74
|
+
align-self: flex-end;
|
|
75
|
+
margin-left: auto;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.chain-ai-message-assistant {
|
|
79
|
+
align-self: flex-start;
|
|
80
|
+
margin-right: auto;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.chain-ai-message-content {
|
|
84
|
+
margin: 0;
|
|
85
|
+
line-height: 1.5;
|
|
86
|
+
white-space: pre-wrap;
|
|
87
|
+
word-wrap: break-word;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.chain-ai-message-timestamp {
|
|
91
|
+
font-size: 11px;
|
|
92
|
+
opacity: 0.7;
|
|
93
|
+
margin-top: 4px;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.chain-ai-input-container {
|
|
97
|
+
display: flex;
|
|
98
|
+
gap: 8px;
|
|
99
|
+
padding: 16px;
|
|
100
|
+
border-top: 1px solid;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.chain-ai-input {
|
|
104
|
+
flex: 1;
|
|
105
|
+
padding: 12px;
|
|
106
|
+
border: 1px solid #e5e7eb;
|
|
107
|
+
border-radius: 6px;
|
|
108
|
+
font-size: 14px;
|
|
109
|
+
outline: none;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.chain-ai-input:focus {
|
|
113
|
+
border-color: #3b82f6;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.chain-ai-input:disabled {
|
|
117
|
+
opacity: 0.5;
|
|
118
|
+
cursor: not-allowed;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.chain-ai-send-button {
|
|
122
|
+
padding: 12px 24px;
|
|
123
|
+
border: none;
|
|
124
|
+
border-radius: 6px;
|
|
125
|
+
font-size: 14px;
|
|
126
|
+
font-weight: 500;
|
|
127
|
+
cursor: pointer;
|
|
128
|
+
transition: opacity 0.2s;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.chain-ai-send-button:hover:not(:disabled) {
|
|
132
|
+
opacity: 0.9;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.chain-ai-send-button:disabled {
|
|
136
|
+
opacity: 0.5;
|
|
137
|
+
cursor: not-allowed;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.chain-ai-loading {
|
|
141
|
+
display: flex;
|
|
142
|
+
align-items: center;
|
|
143
|
+
justify-content: center;
|
|
144
|
+
height: 100%;
|
|
145
|
+
color: #6b7280;
|
|
146
|
+
font-size: 14px;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
.chain-ai-error {
|
|
150
|
+
padding: 12px;
|
|
151
|
+
background-color: #fee2e2;
|
|
152
|
+
color: #dc2626;
|
|
153
|
+
border-radius: 6px;
|
|
154
|
+
margin: 8px 0;
|
|
155
|
+
font-size: 14px;
|
|
156
|
+
}
|