@coinbase/cdp-react 0.0.37 → 0.0.39
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 +2 -1
- package/dist/assets/AmountInput.css +1 -1
- package/dist/assets/AuthButton.css +1 -1
- package/dist/assets/Button.css +1 -1
- package/dist/assets/ButtonBase.css +1 -1
- package/dist/assets/Error.css +1 -1
- package/dist/assets/Field.css +1 -1
- package/dist/assets/Fund.css +1 -1
- package/dist/assets/FundPaymentMethods.css +1 -1
- package/dist/assets/Input.css +1 -1
- package/dist/assets/Modal.css +1 -1
- package/dist/assets/PhoneNumberInput.css +1 -1
- package/dist/assets/Select.css +1 -1
- package/dist/assets/SendEvmTransactionButton.css +1 -0
- package/dist/assets/SendSolanaTransactionButton.css +1 -0
- package/dist/assets/SignIn.css +1 -1
- package/dist/assets/SuccessMessage.css +1 -1
- package/dist/components/CDPReactProvider/index.js +26 -26
- package/dist/components/Fund/FundProvider.js +78 -74
- package/dist/components/Fund/hooks/useBuyUrl.d.ts +1 -2
- package/dist/components/Fund/hooks/useBuyUrl.js +23 -23
- package/dist/components/Fund/types.d.ts +2 -1
- package/dist/components/{SendTransactionButton → SendEvmTransactionButton}/index.d.ts +2 -2
- package/dist/components/SendEvmTransactionButton/index.js +67 -0
- package/dist/components/SendSolanaTransactionButton/index.d.ts +13 -0
- package/dist/components/SendSolanaTransactionButton/index.js +67 -0
- package/dist/components/SignIn/SignInForm.js +38 -24
- package/dist/components/ui/SwitchTransition/index.js +65 -65
- package/dist/index.d.ts +2 -1
- package/dist/index.js +88 -81
- package/dist/theme/index.js +14 -9
- package/dist/theme/theme.d.ts +116 -18
- package/dist/theme/tokens.d.ts +321 -39
- package/dist/theme/tokens.js +117 -25
- package/dist/theme/utils.d.ts +6 -3
- package/dist/theme/utils.js +16 -18
- package/package.json +5 -5
- package/dist/assets/SendTransactionButton.css +0 -1
- package/dist/components/SendTransactionButton/index.js +0 -67
package/dist/theme/tokens.js
CHANGED
|
@@ -15,7 +15,7 @@ const e = {
|
|
|
15
15
|
red500: "#cf202f",
|
|
16
16
|
green500: "#098551",
|
|
17
17
|
amber500: "#ed702f"
|
|
18
|
-
},
|
|
18
|
+
}, o = {
|
|
19
19
|
bg: {
|
|
20
20
|
default: { value: e.white },
|
|
21
21
|
// background
|
|
@@ -23,9 +23,9 @@ const e = {
|
|
|
23
23
|
// alternate background
|
|
24
24
|
contrast: { value: "{colors.fg.default}" },
|
|
25
25
|
// contrast background, used to mix with other backgrounds to create relative colors (i.e. for hover / pressed states)
|
|
26
|
-
overlay: { value: "{colors.bg.alternate}", modify: { type: "alpha", value: 0.33 } },
|
|
26
|
+
overlay: { value: "{colors.bg.alternate}", modify: { type: "color-alpha", value: 0.33 } },
|
|
27
27
|
// overlay background
|
|
28
|
-
skeleton: { value: "{colors.fg.default}", modify: { type: "alpha", value: 0.1 } },
|
|
28
|
+
skeleton: { value: "{colors.fg.default}", modify: { type: "color-alpha", value: 0.1 } },
|
|
29
29
|
// skeleton background
|
|
30
30
|
primary: { value: e.blue500 },
|
|
31
31
|
// primary color background
|
|
@@ -62,7 +62,7 @@ const e = {
|
|
|
62
62
|
negative: { value: "{colors.fg.negative}" }
|
|
63
63
|
// negative line color
|
|
64
64
|
}
|
|
65
|
-
},
|
|
65
|
+
}, a = {
|
|
66
66
|
page: {
|
|
67
67
|
bg: {
|
|
68
68
|
default: { value: "{colors.bg.default}" }
|
|
@@ -81,11 +81,11 @@ const e = {
|
|
|
81
81
|
default: { value: "{colors.bg.primary}" },
|
|
82
82
|
hover: {
|
|
83
83
|
value: "{colors.bg.primary}",
|
|
84
|
-
modify: { type: "mix", value: [["{colors.bg.contrast}", "15%"]] }
|
|
84
|
+
modify: { type: "color-mix", value: [["{colors.bg.contrast}", "15%"]] }
|
|
85
85
|
},
|
|
86
86
|
pressed: {
|
|
87
87
|
value: "{colors.bg.primary}",
|
|
88
|
-
modify: { type: "mix", value: [["{colors.bg.contrast}", "30%"]] }
|
|
88
|
+
modify: { type: "color-mix", value: [["{colors.bg.contrast}", "30%"]] }
|
|
89
89
|
}
|
|
90
90
|
},
|
|
91
91
|
border: {
|
|
@@ -101,11 +101,11 @@ const e = {
|
|
|
101
101
|
default: { value: "{colors.bg.secondary}" },
|
|
102
102
|
hover: {
|
|
103
103
|
value: "{colors.bg.secondary}",
|
|
104
|
-
modify: { type: "mix", value: [["{colors.bg.contrast}", "10%"]] }
|
|
104
|
+
modify: { type: "color-mix", value: [["{colors.bg.contrast}", "10%"]] }
|
|
105
105
|
},
|
|
106
106
|
pressed: {
|
|
107
107
|
value: "{colors.bg.secondary}",
|
|
108
|
-
modify: { type: "mix", value: [["{colors.bg.contrast}", "20%"]] }
|
|
108
|
+
modify: { type: "color-mix", value: [["{colors.bg.contrast}", "20%"]] }
|
|
109
109
|
}
|
|
110
110
|
},
|
|
111
111
|
border: {
|
|
@@ -123,11 +123,11 @@ const e = {
|
|
|
123
123
|
default: { value: "{colors.fg.primary}" },
|
|
124
124
|
hover: {
|
|
125
125
|
value: "{colors.fg.primary}",
|
|
126
|
-
modify: { type: "mix", value: [["{colors.bg.contrast}", "15%"]] }
|
|
126
|
+
modify: { type: "color-mix", value: [["{colors.bg.contrast}", "15%"]] }
|
|
127
127
|
},
|
|
128
128
|
pressed: {
|
|
129
129
|
value: "{colors.fg.primary}",
|
|
130
|
-
modify: { type: "mix", value: [["{colors.bg.contrast}", "30%"]] }
|
|
130
|
+
modify: { type: "color-mix", value: [["{colors.bg.contrast}", "30%"]] }
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
133
|
},
|
|
@@ -136,11 +136,11 @@ const e = {
|
|
|
136
136
|
default: { value: "{colors.fg.default}" },
|
|
137
137
|
hover: {
|
|
138
138
|
value: "{colors.fg.default}",
|
|
139
|
-
modify: { type: "mix", value: [["{colors.bg.contrast}", "10%"]] }
|
|
139
|
+
modify: { type: "color-mix", value: [["{colors.bg.contrast}", "10%"]] }
|
|
140
140
|
},
|
|
141
141
|
pressed: {
|
|
142
142
|
value: "{colors.fg.default}",
|
|
143
|
-
modify: { type: "mix", value: [["{colors.bg.contrast}", "20%"]] }
|
|
143
|
+
modify: { type: "color-mix", value: [["{colors.bg.contrast}", "20%"]] }
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
146
|
}
|
|
@@ -180,11 +180,11 @@ const e = {
|
|
|
180
180
|
default: { value: "{colors.bg.default}" },
|
|
181
181
|
hover: {
|
|
182
182
|
value: "{colors.bg.default}",
|
|
183
|
-
modify: { type: "mix", value: [["{colors.bg.contrast}", "5%"]] }
|
|
183
|
+
modify: { type: "color-mix", value: [["{colors.bg.contrast}", "5%"]] }
|
|
184
184
|
},
|
|
185
185
|
pressed: {
|
|
186
186
|
value: "{colors.bg.default}",
|
|
187
|
-
modify: { type: "mix", value: [["{colors.bg.contrast}", "7%"]] }
|
|
187
|
+
modify: { type: "color-mix", value: [["{colors.bg.contrast}", "7%"]] }
|
|
188
188
|
}
|
|
189
189
|
},
|
|
190
190
|
border: {
|
|
@@ -221,7 +221,7 @@ const e = {
|
|
|
221
221
|
default: { value: "{colors.bg.default}" },
|
|
222
222
|
highlight: {
|
|
223
223
|
value: "{colors.bg.default}",
|
|
224
|
-
modify: { type: "mix", value: [["{colors.bg.contrast}", "10%"]] }
|
|
224
|
+
modify: { type: "color-mix", value: [["{colors.bg.contrast}", "10%"]] }
|
|
225
225
|
}
|
|
226
226
|
},
|
|
227
227
|
text: {
|
|
@@ -244,30 +244,122 @@ const e = {
|
|
|
244
244
|
default: { value: "{colors.fg.default}" }
|
|
245
245
|
}
|
|
246
246
|
}
|
|
247
|
-
}, a = {
|
|
248
|
-
...l,
|
|
249
|
-
...o
|
|
250
247
|
}, r = {
|
|
248
|
+
...o,
|
|
249
|
+
...a
|
|
250
|
+
}, l = {
|
|
251
251
|
family: {
|
|
252
252
|
mono: {
|
|
253
253
|
value: '"DM Mono", monospace'
|
|
254
254
|
},
|
|
255
255
|
sans: {
|
|
256
256
|
value: '"Rethink Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"'
|
|
257
|
+
},
|
|
258
|
+
body: {
|
|
259
|
+
value: "{font.family.sans}"
|
|
260
|
+
},
|
|
261
|
+
interactive: {
|
|
262
|
+
value: "{font.family.sans}"
|
|
257
263
|
}
|
|
258
264
|
},
|
|
259
265
|
size: {
|
|
260
266
|
base: { value: 16 }
|
|
261
267
|
}
|
|
262
268
|
}, t = {
|
|
263
|
-
|
|
264
|
-
|
|
269
|
+
family: {
|
|
270
|
+
page: {
|
|
271
|
+
value: "{font.family.body}"
|
|
272
|
+
},
|
|
273
|
+
cta: {
|
|
274
|
+
value: "{font.family.interactive}"
|
|
275
|
+
},
|
|
276
|
+
link: {
|
|
277
|
+
value: "{font.family.interactive}"
|
|
278
|
+
},
|
|
279
|
+
input: {
|
|
280
|
+
value: "{font.family.interactive}"
|
|
281
|
+
},
|
|
282
|
+
select: {
|
|
283
|
+
value: "{font.family.interactive}"
|
|
284
|
+
},
|
|
285
|
+
code: {
|
|
286
|
+
value: "{font.family.mono}"
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
}, u = {
|
|
290
|
+
family: {
|
|
291
|
+
...l.family,
|
|
292
|
+
...t.family
|
|
293
|
+
},
|
|
294
|
+
size: {
|
|
295
|
+
...l.size
|
|
296
|
+
}
|
|
297
|
+
}, s = {
|
|
298
|
+
none: {
|
|
299
|
+
value: 0
|
|
300
|
+
},
|
|
301
|
+
xs: {
|
|
302
|
+
value: "{font.size.base}",
|
|
303
|
+
modify: { type: "multiply", value: 0.25 }
|
|
304
|
+
},
|
|
305
|
+
sm: {
|
|
306
|
+
value: "{font.size.base}",
|
|
307
|
+
modify: { type: "multiply", value: 0.5 }
|
|
308
|
+
},
|
|
309
|
+
md: {
|
|
310
|
+
value: "{font.size.base}",
|
|
311
|
+
modify: { type: "multiply", value: 0.75 }
|
|
312
|
+
},
|
|
313
|
+
lg: {
|
|
314
|
+
value: "{font.size.base}",
|
|
315
|
+
modify: { type: "multiply", value: 1 }
|
|
316
|
+
},
|
|
317
|
+
xl: {
|
|
318
|
+
value: "{font.size.base}",
|
|
319
|
+
modify: { type: "multiply", value: 1.5 }
|
|
320
|
+
},
|
|
321
|
+
full: {
|
|
322
|
+
value: 99999
|
|
323
|
+
}
|
|
324
|
+
}, c = {
|
|
325
|
+
cta: {
|
|
326
|
+
value: "{borderRadius.full}"
|
|
327
|
+
},
|
|
328
|
+
input: {
|
|
329
|
+
value: "{borderRadius.sm}"
|
|
330
|
+
},
|
|
331
|
+
link: {
|
|
332
|
+
value: "{borderRadius.full}"
|
|
333
|
+
},
|
|
334
|
+
modal: {
|
|
335
|
+
value: "{borderRadius.sm}"
|
|
336
|
+
},
|
|
337
|
+
select: {
|
|
338
|
+
trigger: {
|
|
339
|
+
value: "{borderRadius.sm}"
|
|
340
|
+
},
|
|
341
|
+
list: {
|
|
342
|
+
value: "{borderRadius.sm}"
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
}, i = {
|
|
346
|
+
...s,
|
|
347
|
+
...c
|
|
348
|
+
}, f = {
|
|
349
|
+
borderRadius: i,
|
|
350
|
+
colors: r,
|
|
351
|
+
font: u
|
|
265
352
|
};
|
|
266
353
|
export {
|
|
267
|
-
|
|
354
|
+
i as borderRadius,
|
|
355
|
+
c as borderRadiusComponents,
|
|
356
|
+
s as borderRadiusSemantic,
|
|
357
|
+
r as colors,
|
|
268
358
|
e as colorsBase,
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
t as
|
|
359
|
+
a as colorsComponents,
|
|
360
|
+
o as colorsSemantic,
|
|
361
|
+
u as font,
|
|
362
|
+
t as fontComponents,
|
|
363
|
+
l as fontSemantic,
|
|
364
|
+
f as tokens
|
|
273
365
|
};
|
package/dist/theme/utils.d.ts
CHANGED
|
@@ -9,14 +9,17 @@ export type Flattened<T extends Record<string, unknown>> = {
|
|
|
9
9
|
export type TokenValue = {
|
|
10
10
|
value: string | number;
|
|
11
11
|
modify?: {
|
|
12
|
-
type: "alpha";
|
|
12
|
+
type: "color-alpha";
|
|
13
13
|
value: number | string;
|
|
14
14
|
} | {
|
|
15
|
-
type: "hsl";
|
|
15
|
+
type: "color-hsl";
|
|
16
16
|
value: [number, number, number];
|
|
17
17
|
} | {
|
|
18
|
-
type: "mix";
|
|
18
|
+
type: "color-mix";
|
|
19
19
|
value: ReadonlyArray<string | readonly [string, string]>;
|
|
20
|
+
} | {
|
|
21
|
+
type: "multiply";
|
|
22
|
+
value: number | string;
|
|
20
23
|
};
|
|
21
24
|
};
|
|
22
25
|
export type NestedTokenObject = {
|
package/dist/theme/utils.js
CHANGED
|
@@ -1,42 +1,40 @@
|
|
|
1
|
-
function
|
|
1
|
+
function u(t) {
|
|
2
2
|
return typeof t == "object" && t !== null && "value" in t && (typeof t.value == "string" || typeof t.value == "number");
|
|
3
3
|
}
|
|
4
4
|
function p(t, e = "cdp-web") {
|
|
5
5
|
const o = {};
|
|
6
6
|
function n(r, c) {
|
|
7
|
-
for (const
|
|
8
|
-
if (Object.prototype.hasOwnProperty.call(r,
|
|
9
|
-
const f = [...c,
|
|
10
|
-
if (
|
|
11
|
-
const
|
|
12
|
-
o[
|
|
7
|
+
for (const l in r)
|
|
8
|
+
if (Object.prototype.hasOwnProperty.call(r, l)) {
|
|
9
|
+
const f = [...c, l], i = r[l];
|
|
10
|
+
if (u(i)) {
|
|
11
|
+
const y = f.join("-");
|
|
12
|
+
o[y] = a(i, e);
|
|
13
13
|
} else typeof i == "object" && i !== null && n(i, f);
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
return n(t, []), o;
|
|
17
17
|
}
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const o = l(t.value, e);
|
|
22
|
-
if (t.modify?.type === "alpha")
|
|
18
|
+
const s = (t, e) => t.startsWith("{") && t.endsWith("}") ? `var(--${e ? `${e}-` : ""}${t.slice(1, -1).replace(/\./g, "-")})` : t, a = (t, e) => {
|
|
19
|
+
const o = typeof t.value == "number" ? `${t.value}px` : s(t.value, e);
|
|
20
|
+
if (t.modify?.type === "color-alpha")
|
|
23
21
|
return `color(from ${o} srgb r g b / ${t.modify.value ?? 1})`;
|
|
24
|
-
if (t.modify?.type === "hsl") {
|
|
22
|
+
if (t.modify?.type === "color-hsl") {
|
|
25
23
|
const [n, r, c] = t.modify.value;
|
|
26
24
|
return `hsl(from ${o} calc(h * ${n}) calc(s * ${r}) calc(l * ${c}))`;
|
|
27
25
|
}
|
|
28
|
-
if (t.modify?.type === "mix") {
|
|
26
|
+
if (t.modify?.type === "color-mix") {
|
|
29
27
|
let n = o;
|
|
30
28
|
return t.modify.value.forEach((r) => {
|
|
31
29
|
if (typeof r == "string")
|
|
32
|
-
n += `, ${
|
|
30
|
+
n += `, ${s(r, e)}`;
|
|
33
31
|
else {
|
|
34
|
-
const [c,
|
|
35
|
-
n += `, ${
|
|
32
|
+
const [c, l] = r;
|
|
33
|
+
n += `, ${s(c, e)} ${l}`;
|
|
36
34
|
}
|
|
37
35
|
}), `color-mix(in oklab, ${n})`;
|
|
38
36
|
}
|
|
39
|
-
return o;
|
|
37
|
+
return t.modify?.type === "multiply" ? `calc(${o} * ${t.modify.value})` : o;
|
|
40
38
|
}, m = (t) => Object.entries(t).reduce((e, [o, n]) => (e[`--cdp-web-${o}`] = n, e), {});
|
|
41
39
|
export {
|
|
42
40
|
p as flattenTokensObject,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coinbase/cdp-react",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.39",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@internationalized/number": "3.6.4",
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
},
|
|
15
15
|
"peerDependencies": {
|
|
16
16
|
"react": ">=18.2.0",
|
|
17
|
-
"@coinbase/cdp-core": "^0.0.
|
|
18
|
-
"@coinbase/cdp-hooks": "^0.0.
|
|
17
|
+
"@coinbase/cdp-core": "^0.0.39",
|
|
18
|
+
"@coinbase/cdp-hooks": "^0.0.39"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"@size-limit/preset-big-lib": "^11.2.0",
|
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
"vite": "^7.0.4",
|
|
46
46
|
"vite-plugin-dts": "^4.5.4",
|
|
47
47
|
"vite-plugin-lib-inject-css": "^2.2.2",
|
|
48
|
-
"@coinbase/cdp-core": "^0.0.
|
|
49
|
-
"@coinbase/cdp-hooks": "^0.0.
|
|
48
|
+
"@coinbase/cdp-core": "^0.0.39",
|
|
49
|
+
"@coinbase/cdp-hooks": "^0.0.39"
|
|
50
50
|
},
|
|
51
51
|
"size-limit": [
|
|
52
52
|
{
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
.SendTransactionButton-module__send-transaction-button___-6UsN{padding-left:2em;padding-right:2em}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { jsx as b } from "react/jsx-runtime";
|
|
2
|
-
import { useSendEvmTransaction as y, APIError as T } from "@coinbase/cdp-hooks";
|
|
3
|
-
import { useState as _, useCallback as v } from "react";
|
|
4
|
-
import { Button as w } from "../ui/Button/index.js";
|
|
5
|
-
import "../../theme/theme.js";
|
|
6
|
-
import { getMessageFromUnknownError as B } from "../../utils/getMessageFromUnknownError.js";
|
|
7
|
-
import '../../assets/SendTransactionButton.css';const P = {
|
|
8
|
-
"send-transaction-button": "SendTransactionButton-module__send-transaction-button___-6UsN"
|
|
9
|
-
}, N = ({
|
|
10
|
-
account: s,
|
|
11
|
-
children: f,
|
|
12
|
-
className: l = "",
|
|
13
|
-
network: r,
|
|
14
|
-
onClick: o,
|
|
15
|
-
onError: a,
|
|
16
|
-
onSuccess: i,
|
|
17
|
-
pendingLabel: u,
|
|
18
|
-
transaction: e,
|
|
19
|
-
variant: p = "primary",
|
|
20
|
-
...g
|
|
21
|
-
}) => {
|
|
22
|
-
const [h, c] = _(!1), { sendEvmTransaction: m } = y(), E = v(
|
|
23
|
-
async (d) => {
|
|
24
|
-
d.preventDefault(), o?.(d);
|
|
25
|
-
try {
|
|
26
|
-
if (!s || !r || !e) {
|
|
27
|
-
const n = [];
|
|
28
|
-
throw s || n.push("account"), r || n.push("network"), e || n.push("transaction"), new Error(`Missing required parameters: ${n.join(", ")}`);
|
|
29
|
-
}
|
|
30
|
-
c(!0);
|
|
31
|
-
const { transactionHash: t } = await m({
|
|
32
|
-
transaction: e,
|
|
33
|
-
evmAccount: s,
|
|
34
|
-
network: r
|
|
35
|
-
});
|
|
36
|
-
i?.(t);
|
|
37
|
-
} catch (t) {
|
|
38
|
-
let n;
|
|
39
|
-
if (t instanceof T || t instanceof Error)
|
|
40
|
-
n = t;
|
|
41
|
-
else {
|
|
42
|
-
const S = B(t);
|
|
43
|
-
n = new Error(S);
|
|
44
|
-
}
|
|
45
|
-
a?.(n);
|
|
46
|
-
} finally {
|
|
47
|
-
c(!1);
|
|
48
|
-
}
|
|
49
|
-
},
|
|
50
|
-
[s, r, o, a, i, m, e]
|
|
51
|
-
);
|
|
52
|
-
return /* @__PURE__ */ b(
|
|
53
|
-
w,
|
|
54
|
-
{
|
|
55
|
-
className: `${P["send-transaction-button"]} ${l}`,
|
|
56
|
-
isPending: h,
|
|
57
|
-
pendingLabel: u || "Sending transaction...",
|
|
58
|
-
onClick: E,
|
|
59
|
-
variant: p,
|
|
60
|
-
...g,
|
|
61
|
-
children: f || "Send transaction"
|
|
62
|
-
}
|
|
63
|
-
);
|
|
64
|
-
};
|
|
65
|
-
export {
|
|
66
|
-
N as SendTransactionButton
|
|
67
|
-
};
|