@voyage_ai/v402-web-ts 0.1.0 → 0.1.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 +639 -1
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +585 -223
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +585 -223
- package/dist/index.mjs.map +1 -1
- package/dist/react/components/PaymentButton.tsx +12 -5
- package/dist/react/components/WalletConnect.tsx +47 -20
- package/dist/react/hooks/useWallet.ts +35 -8
- package/dist/react/index.d.mts +2 -2
- package/dist/react/index.d.ts +2 -2
- package/dist/react/index.js +653 -33
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +655 -35
- package/dist/react/index.mjs.map +1 -1
- package/dist/react/store/walletStore.ts +29 -0
- package/dist/react/styles/inline-styles.ts +227 -0
- package/dist/react/styles.css +8 -1
- package/package.json +8 -6
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Inline styles for x402 React Components
|
|
3
|
+
*
|
|
4
|
+
* Modern, minimal, and flat design without gradients or fancy borders.
|
|
5
|
+
* All styles are defined as JavaScript objects to ensure they're always bundled
|
|
6
|
+
* with the components. This eliminates the need for users to import CSS files.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import {CSSProperties} from 'react';
|
|
10
|
+
|
|
11
|
+
// 检测是否支持暗色模式
|
|
12
|
+
export const isDarkMode = (): boolean => {
|
|
13
|
+
if (typeof window === 'undefined') return false;
|
|
14
|
+
return window.matchMedia?.('(prefers-color-scheme: dark)').matches ?? false;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
// 现代简约配色 - 扁平化设计
|
|
18
|
+
const colors = {
|
|
19
|
+
// Light mode
|
|
20
|
+
light: {
|
|
21
|
+
background: '#fafafa',
|
|
22
|
+
cardBg: '#ffffff',
|
|
23
|
+
text: '#0a0a0a',
|
|
24
|
+
textSecondary: '#737373',
|
|
25
|
+
primary: '#000000',
|
|
26
|
+
primaryHover: '#262626',
|
|
27
|
+
danger: '#ef4444',
|
|
28
|
+
dangerHover: '#dc2626',
|
|
29
|
+
success: '#10b981',
|
|
30
|
+
successHover: '#059669',
|
|
31
|
+
disabled: '#e5e5e5',
|
|
32
|
+
disabledText: '#a3a3a3',
|
|
33
|
+
errorBg: '#fef2f2',
|
|
34
|
+
errorText: '#dc2626',
|
|
35
|
+
},
|
|
36
|
+
// Dark mode
|
|
37
|
+
dark: {
|
|
38
|
+
background: '#0a0a0a',
|
|
39
|
+
cardBg: '#171717',
|
|
40
|
+
text: '#fafafa',
|
|
41
|
+
textSecondary: '#a3a3a3',
|
|
42
|
+
primary: '#ffffff',
|
|
43
|
+
primaryHover: '#e5e5e5',
|
|
44
|
+
danger: '#f87171',
|
|
45
|
+
dangerHover: '#ef4444',
|
|
46
|
+
success: '#34d399',
|
|
47
|
+
successHover: '#10b981',
|
|
48
|
+
disabled: '#262626',
|
|
49
|
+
disabledText: '#525252',
|
|
50
|
+
errorBg: '#1c1917',
|
|
51
|
+
errorText: '#f87171',
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
// 获取当前主题颜色
|
|
56
|
+
export const getColors = () => {
|
|
57
|
+
return isDarkMode() ? colors.dark : colors.light;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
// 容器样式
|
|
61
|
+
export const containerStyle: CSSProperties = {
|
|
62
|
+
width: '100%',
|
|
63
|
+
maxWidth: '420px',
|
|
64
|
+
margin: '0 auto',
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
// 钱包区块样式 - 极简无边框
|
|
68
|
+
export const getSectionStyle = (): CSSProperties => {
|
|
69
|
+
const c = getColors();
|
|
70
|
+
return {
|
|
71
|
+
padding: '1.5rem',
|
|
72
|
+
background: c.cardBg,
|
|
73
|
+
borderRadius: '12px',
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
// 标题样式 - 简洁
|
|
78
|
+
export const getTitleStyle = (): CSSProperties => {
|
|
79
|
+
const c = getColors();
|
|
80
|
+
return {
|
|
81
|
+
margin: '0 0 1.25rem 0',
|
|
82
|
+
fontSize: '1.125rem',
|
|
83
|
+
fontWeight: 600,
|
|
84
|
+
color: c.text,
|
|
85
|
+
letterSpacing: '-0.01em',
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
// 按钮容器样式
|
|
90
|
+
export const buttonsContainerStyle: CSSProperties = {
|
|
91
|
+
display: 'flex',
|
|
92
|
+
flexDirection: 'column',
|
|
93
|
+
gap: '0.75rem',
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
// 钱包选项样式
|
|
97
|
+
export const walletOptionStyle: CSSProperties = {
|
|
98
|
+
display: 'flex',
|
|
99
|
+
flexDirection: 'column',
|
|
100
|
+
gap: '0.5rem',
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
// 基础按钮样式 - 扁平化
|
|
104
|
+
const baseButtonStyle: CSSProperties = {
|
|
105
|
+
padding: '0.875rem 1.25rem',
|
|
106
|
+
fontSize: '0.9375rem',
|
|
107
|
+
fontWeight: 500,
|
|
108
|
+
border: 'none',
|
|
109
|
+
borderRadius: '8px',
|
|
110
|
+
cursor: 'pointer',
|
|
111
|
+
transition: 'background-color 0.15s ease, opacity 0.15s ease',
|
|
112
|
+
outline: 'none',
|
|
113
|
+
letterSpacing: '-0.01em',
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
// 连接按钮样式 - 纯黑/纯白
|
|
117
|
+
export const getConnectButtonStyle = (isDisabled: boolean, isHovered: boolean): CSSProperties => {
|
|
118
|
+
const c = getColors();
|
|
119
|
+
return {
|
|
120
|
+
...baseButtonStyle,
|
|
121
|
+
background: isDisabled ? c.disabled : (isHovered ? c.primaryHover : c.primary),
|
|
122
|
+
color: isDarkMode() ? '#000000' : '#ffffff',
|
|
123
|
+
cursor: isDisabled ? 'not-allowed' : 'pointer',
|
|
124
|
+
opacity: isDisabled ? 0.5 : 1,
|
|
125
|
+
};
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
// 断开连接按钮样式
|
|
129
|
+
export const getDisconnectButtonStyle = (isHovered: boolean): CSSProperties => {
|
|
130
|
+
const c = getColors();
|
|
131
|
+
return {
|
|
132
|
+
...baseButtonStyle,
|
|
133
|
+
background: isHovered ? c.dangerHover : c.danger,
|
|
134
|
+
color: '#ffffff',
|
|
135
|
+
};
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
// 支付按钮样式
|
|
139
|
+
export const getPayButtonStyle = (isDisabled: boolean, isHovered: boolean): CSSProperties => {
|
|
140
|
+
const c = getColors();
|
|
141
|
+
return {
|
|
142
|
+
...baseButtonStyle,
|
|
143
|
+
background: isDisabled ? c.disabled : (isHovered ? c.successHover : c.success),
|
|
144
|
+
color: '#ffffff',
|
|
145
|
+
width: '100%',
|
|
146
|
+
cursor: isDisabled ? 'not-allowed' : 'pointer',
|
|
147
|
+
opacity: isDisabled ? 0.5 : 1,
|
|
148
|
+
};
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
// 安装链接样式 - 简洁
|
|
152
|
+
export const getInstallLinkStyle = (isHovered: boolean): CSSProperties => {
|
|
153
|
+
const c = getColors();
|
|
154
|
+
return {
|
|
155
|
+
display: 'inline-block',
|
|
156
|
+
padding: '0.5rem',
|
|
157
|
+
fontSize: '0.8125rem',
|
|
158
|
+
color: c.textSecondary,
|
|
159
|
+
textDecoration: isHovered ? 'underline' : 'none',
|
|
160
|
+
textAlign: 'center',
|
|
161
|
+
fontWeight: 500,
|
|
162
|
+
};
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
// 钱包地址容器样式
|
|
166
|
+
export const walletAddressStyle: CSSProperties = {
|
|
167
|
+
display: 'flex',
|
|
168
|
+
flexDirection: 'column',
|
|
169
|
+
gap: '0.5rem',
|
|
170
|
+
marginBottom: '1rem',
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
// 钱包标签样式
|
|
174
|
+
export const getLabelStyle = (): CSSProperties => {
|
|
175
|
+
const c = getColors();
|
|
176
|
+
return {
|
|
177
|
+
fontSize: '0.8125rem',
|
|
178
|
+
color: c.textSecondary,
|
|
179
|
+
fontWeight: 500,
|
|
180
|
+
textTransform: 'uppercase',
|
|
181
|
+
letterSpacing: '0.05em',
|
|
182
|
+
};
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
// 地址样式
|
|
186
|
+
export const getAddressStyle = (): CSSProperties => {
|
|
187
|
+
const c = getColors();
|
|
188
|
+
return {
|
|
189
|
+
fontFamily: 'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace',
|
|
190
|
+
fontSize: '0.9375rem',
|
|
191
|
+
fontWeight: 500,
|
|
192
|
+
color: c.text,
|
|
193
|
+
letterSpacing: '-0.01em',
|
|
194
|
+
};
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
// 钱包操作区域样式
|
|
198
|
+
export const walletActionsStyle: CSSProperties = {
|
|
199
|
+
margin: '1rem 0',
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
// 提示文字样式
|
|
203
|
+
export const getHintStyle = (): CSSProperties => {
|
|
204
|
+
const c = getColors();
|
|
205
|
+
return {
|
|
206
|
+
marginTop: '1rem',
|
|
207
|
+
fontSize: '0.8125rem',
|
|
208
|
+
color: c.textSecondary,
|
|
209
|
+
textAlign: 'center',
|
|
210
|
+
lineHeight: '1.5',
|
|
211
|
+
};
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
// 错误信息样式 - 扁平化
|
|
215
|
+
export const getErrorStyle = (): CSSProperties => {
|
|
216
|
+
const c = getColors();
|
|
217
|
+
return {
|
|
218
|
+
marginTop: '1rem',
|
|
219
|
+
padding: '0.75rem 1rem',
|
|
220
|
+
background: c.errorBg,
|
|
221
|
+
color: c.errorText,
|
|
222
|
+
borderRadius: '8px',
|
|
223
|
+
fontSize: '0.8125rem',
|
|
224
|
+
fontWeight: 500,
|
|
225
|
+
};
|
|
226
|
+
};
|
|
227
|
+
|
package/dist/react/styles.css
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* x402 React Components - Default Styles
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* ⚠️ DEPRECATED: This CSS file is no longer needed!
|
|
5
|
+
*
|
|
6
|
+
* All styles are now inline within the components.
|
|
7
|
+
* You can safely remove any imports of this file:
|
|
8
|
+
* - import '@voyage_ai/v402-web-ts/react/styles.css' ❌
|
|
9
|
+
* - import '@voyage_ai/v402-web-ts/styles.css' ❌
|
|
10
|
+
*
|
|
11
|
+
* Just use the components directly - styles are built-in! ✅
|
|
5
12
|
*/
|
|
6
13
|
|
|
7
14
|
.x402-wallet-connect {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@voyage_ai/v402-web-ts",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "v402pay platform frontend SDK for seamless Web3 payment integration with Solana and Ethereum support",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
@@ -15,9 +15,7 @@
|
|
|
15
15
|
"import": "./dist/react/index.mjs",
|
|
16
16
|
"require": "./dist/react/index.js",
|
|
17
17
|
"types": "./dist/react/index.d.ts"
|
|
18
|
-
}
|
|
19
|
-
"./react/styles.css": "./dist/react/styles.css",
|
|
20
|
-
"./styles.css": "./dist/react/styles.css"
|
|
18
|
+
}
|
|
21
19
|
},
|
|
22
20
|
"files": [
|
|
23
21
|
"dist",
|
|
@@ -27,7 +25,11 @@
|
|
|
27
25
|
"build": "tsup",
|
|
28
26
|
"dev": "tsup --watch",
|
|
29
27
|
"type-check": "tsc --noEmit",
|
|
30
|
-
"prepublishOnly": "npm run build"
|
|
28
|
+
"prepublishOnly": "npm run build",
|
|
29
|
+
"release": "npm run release:patch",
|
|
30
|
+
"release:patch": "npm version patch && npm publish && git push --follow-tags",
|
|
31
|
+
"release:minor": "npm version minor && npm publish && git push --follow-tags",
|
|
32
|
+
"release:major": "npm version major && npm publish && git push --follow-tags"
|
|
31
33
|
},
|
|
32
34
|
"keywords": [
|
|
33
35
|
"x402",
|