@coinbase/cdp-react 0.0.71 → 0.0.73
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/dist/components/ui/IframeButton/index.js +89 -88
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +5 -5
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { c as
|
|
3
|
-
import { forwardRef as
|
|
4
|
-
import { useTheme as
|
|
5
|
-
import { LoadingSkeleton as
|
|
1
|
+
import { jsxs as H, jsx as B } from "react/jsx-runtime";
|
|
2
|
+
import { c as F } from "../../../chunks/lite.1fxw3LjI.js";
|
|
3
|
+
import { forwardRef as R, useRef as y, useMemo as C, useState as U, useEffect as T } from "react";
|
|
4
|
+
import { useTheme as L } from "../../ThemeProvider/index.js";
|
|
5
|
+
import { LoadingSkeleton as W } from "../LoadingSkeleton/index.js";
|
|
6
6
|
import "../../../theme/theme.js";
|
|
7
|
-
import { colorsBase as
|
|
8
|
-
import '../../../assets/IframeButton.css';const
|
|
7
|
+
import { colorsBase as i } from "../../../theme/tokens.js";
|
|
8
|
+
import '../../../assets/IframeButton.css';const N = "IframeButton-module__label___Vvl8W", P = "IframeButton-module__iframe___0RBLL", j = "IframeButton-module__hidden___LcF1X", s = {
|
|
9
9
|
"iframe-button": "IframeButton-module__iframe-button___XeAhH",
|
|
10
10
|
"full-width": "IframeButton-module__full-width___lQWpM",
|
|
11
11
|
"size-lg": "IframeButton-module__size-lg___HCOiF",
|
|
@@ -13,153 +13,154 @@ import '../../../assets/IframeButton.css';const C = "IframeButton-module__label_
|
|
|
13
13
|
"size-sm": "IframeButton-module__size-sm___U8ILi",
|
|
14
14
|
"size-xs": "IframeButton-module__size-xs___S2jGa",
|
|
15
15
|
"loading-skeleton": "IframeButton-module__loading-skeleton___fzBol",
|
|
16
|
-
label:
|
|
16
|
+
label: N,
|
|
17
17
|
"with-icon": "IframeButton-module__with-icon___KBiq1",
|
|
18
|
-
iframe:
|
|
19
|
-
hidden:
|
|
18
|
+
iframe: P,
|
|
19
|
+
hidden: j,
|
|
20
20
|
"computed-style": "IframeButton-module__computed-style___ciB13"
|
|
21
|
-
},
|
|
22
|
-
pageBg:
|
|
23
|
-
buttonBg:
|
|
21
|
+
}, k = {
|
|
22
|
+
pageBg: i.white,
|
|
23
|
+
buttonBg: i.blue500,
|
|
24
24
|
buttonBgHover: "#0748d6",
|
|
25
25
|
buttonBgPressed: "#0b3eae",
|
|
26
|
-
buttonBgFocus:
|
|
27
|
-
buttonBorder:
|
|
26
|
+
buttonBgFocus: i.blue550,
|
|
27
|
+
buttonBorder: i.blue550,
|
|
28
28
|
buttonBorderHover: "#0748d6",
|
|
29
29
|
buttonBorderPressed: "#0b3eae",
|
|
30
|
-
buttonBorderFocus:
|
|
31
|
-
buttonBorderFocusInset:
|
|
32
|
-
buttonText:
|
|
33
|
-
buttonTextHover:
|
|
34
|
-
buttonTextPressed:
|
|
35
|
-
buttonTextFocus:
|
|
30
|
+
buttonBorderFocus: i.blue550,
|
|
31
|
+
buttonBorderFocusInset: i.white,
|
|
32
|
+
buttonText: i.white,
|
|
33
|
+
buttonTextHover: i.white,
|
|
34
|
+
buttonTextPressed: i.white,
|
|
35
|
+
buttonTextFocus: i.white,
|
|
36
36
|
buttonBorderRadius: 99999,
|
|
37
37
|
buttonFontSize: 16,
|
|
38
38
|
buttonFontWeight: 500,
|
|
39
39
|
buttonSize: "md",
|
|
40
40
|
fontUrl: "",
|
|
41
41
|
fontFamily: ""
|
|
42
|
-
},
|
|
43
|
-
(e) => e === "fontUrl" || e === "buttonSize" ? !0 :
|
|
44
|
-
), f = (
|
|
45
|
-
if (!
|
|
46
|
-
return console.warn("Invalid color input:",
|
|
47
|
-
const t =
|
|
42
|
+
}, $ = Object.keys(k), q = (o) => $.every(
|
|
43
|
+
(e) => e === "fontUrl" || e === "buttonSize" ? !0 : o[e] !== void 0
|
|
44
|
+
), v = (o, e) => o === e ? !0 : !o || !e ? !1 : $.every((t) => o[t] === e[t]), f = (o, e, t) => (e.style.backgroundColor = `var(--cdp-web-${o})`, A(getComputedStyle(e).backgroundColor, t)), A = (o, e) => {
|
|
45
|
+
if (!o || typeof o != "string")
|
|
46
|
+
return console.warn("Invalid color input:", o), "";
|
|
47
|
+
const t = o.trim();
|
|
48
48
|
if (t.startsWith("#"))
|
|
49
49
|
return /^#[0-9A-Fa-f]{6}([0-9A-Fa-f]{2})?$/.test(t) ? t.toLowerCase() : (console.warn("Invalid hex color:", t), "");
|
|
50
50
|
if (t === "transparent") return "transparent";
|
|
51
51
|
if (t === "none") return "none";
|
|
52
|
-
const
|
|
53
|
-
if (!
|
|
52
|
+
const r = e.getContext("2d", { willReadFrequently: !0 });
|
|
53
|
+
if (!r)
|
|
54
54
|
return console.warn("Could not create canvas context"), "";
|
|
55
|
-
if (
|
|
56
|
-
return
|
|
57
|
-
|
|
58
|
-
const a =
|
|
59
|
-
if (
|
|
60
|
-
const b =
|
|
61
|
-
return `#${d}${u}${
|
|
55
|
+
if (r.fillStyle = t, r.fillStyle.startsWith("#"))
|
|
56
|
+
return r.fillStyle.toLowerCase();
|
|
57
|
+
r.fillRect(0, 0, 1, 1);
|
|
58
|
+
const a = r.getImageData(0, 0, 1, 1), [m, n, c, l] = a.data, d = m.toString(16).padStart(2, "0"), u = n.toString(16).padStart(2, "0"), _ = c.toString(16).padStart(2, "0");
|
|
59
|
+
if (l < 255) {
|
|
60
|
+
const b = l.toString(16).padStart(2, "0");
|
|
61
|
+
return `#${d}${u}${_}${b}`;
|
|
62
62
|
}
|
|
63
|
-
return `#${d}${u}${
|
|
64
|
-
},
|
|
65
|
-
const a = getComputedStyle(t), m = f("colors-page-bg-default", t,
|
|
63
|
+
return `#${d}${u}${_}`;
|
|
64
|
+
}, M = (o, e, t, r) => {
|
|
65
|
+
const a = getComputedStyle(t), m = f("colors-page-bg-default", t, r), n = f(`colors-cta-${e}-bg-default`, t, r), c = f(`colors-cta-${e}-bg-hover`, t, r), l = f(`colors-cta-${e}-bg-pressed`, t, r), d = f(`colors-cta-${e}-text-default`, t, r);
|
|
66
66
|
return {
|
|
67
67
|
pageBg: m,
|
|
68
|
-
buttonBg:
|
|
68
|
+
buttonBg: n,
|
|
69
69
|
buttonBgHover: c,
|
|
70
|
-
buttonBgPressed:
|
|
71
|
-
buttonBgFocus:
|
|
72
|
-
buttonBorder:
|
|
70
|
+
buttonBgPressed: l,
|
|
71
|
+
buttonBgFocus: n,
|
|
72
|
+
buttonBorder: n,
|
|
73
73
|
buttonBorderHover: c,
|
|
74
|
-
buttonBorderPressed:
|
|
75
|
-
buttonBorderFocus: f(`colors-cta-${e}-border-focus`, t,
|
|
74
|
+
buttonBorderPressed: l,
|
|
75
|
+
buttonBorderFocus: f(`colors-cta-${e}-border-focus`, t, r),
|
|
76
76
|
buttonBorderFocusInset: m,
|
|
77
77
|
buttonBorderRadius: parseInt(a.borderRadius),
|
|
78
78
|
buttonFontSize: parseInt(a.fontSize),
|
|
79
79
|
buttonFontWeight: parseInt(a.fontWeight),
|
|
80
80
|
buttonText: d,
|
|
81
|
-
buttonTextHover: f(`colors-cta-${e}-text-hover`, t,
|
|
81
|
+
buttonTextHover: f(`colors-cta-${e}-text-hover`, t, r),
|
|
82
82
|
buttonTextPressed: d,
|
|
83
83
|
buttonTextFocus: d,
|
|
84
|
-
buttonSize:
|
|
84
|
+
buttonSize: o ?? "md",
|
|
85
85
|
fontFamily: a.fontFamily,
|
|
86
86
|
fontUrl: ""
|
|
87
87
|
};
|
|
88
|
-
},
|
|
88
|
+
}, V = {
|
|
89
89
|
xs: s["size-xs"],
|
|
90
90
|
sm: s["size-sm"],
|
|
91
91
|
md: s["size-md"],
|
|
92
92
|
lg: s["size-lg"]
|
|
93
|
-
},
|
|
93
|
+
}, D = R(
|
|
94
94
|
({
|
|
95
|
-
className:
|
|
95
|
+
className: o = "",
|
|
96
96
|
isPending: e,
|
|
97
97
|
label: t,
|
|
98
|
-
icon:
|
|
98
|
+
icon: r,
|
|
99
99
|
fullWidth: a,
|
|
100
100
|
size: m,
|
|
101
|
-
theme:
|
|
101
|
+
theme: n,
|
|
102
102
|
onThemeChange: c,
|
|
103
|
-
...
|
|
103
|
+
...l
|
|
104
104
|
}, d) => {
|
|
105
|
-
const u = m === "none" ? "md" : m, { theme:
|
|
106
|
-
|
|
107
|
-
...
|
|
108
|
-
fontUrl:
|
|
105
|
+
const u = m === "none" ? "md" : m, { theme: _ } = L(), b = _["font-url-iframe"], p = y(null), x = y(null), h = C(() => !!n && q(n), [n]), [S, z] = U(
|
|
106
|
+
h ? {
|
|
107
|
+
...n,
|
|
108
|
+
fontUrl: n?.fontUrl ?? b,
|
|
109
109
|
buttonSize: u ?? "md"
|
|
110
110
|
} : void 0
|
|
111
111
|
);
|
|
112
|
-
return
|
|
113
|
-
if (
|
|
114
|
-
|
|
115
|
-
...
|
|
116
|
-
fontUrl:
|
|
112
|
+
return T(() => {
|
|
113
|
+
if (h) {
|
|
114
|
+
const g = {
|
|
115
|
+
...n,
|
|
116
|
+
fontUrl: n?.fontUrl ?? b,
|
|
117
117
|
buttonSize: u ?? "md"
|
|
118
|
-
}
|
|
118
|
+
};
|
|
119
|
+
z((w) => v(g, w) ? w : g);
|
|
119
120
|
return;
|
|
120
121
|
}
|
|
121
|
-
if (!p.current || !
|
|
122
|
-
const
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
...w,
|
|
122
|
+
if (!p.current || !x.current) return;
|
|
123
|
+
const I = {
|
|
124
|
+
...M(
|
|
125
|
+
u ?? "md",
|
|
126
|
+
l.variant ?? "primary",
|
|
127
|
+
p.current,
|
|
128
|
+
x.current
|
|
129
|
+
),
|
|
130
130
|
fontUrl: b,
|
|
131
|
-
...
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
131
|
+
...n
|
|
132
|
+
};
|
|
133
|
+
z((g) => v(I, g) ? g : I);
|
|
134
|
+
}, [l.variant, u, h, n, b, _]), T(() => {
|
|
135
|
+
S && c?.(S);
|
|
136
|
+
}, [S, c]), /* @__PURE__ */ H(
|
|
136
137
|
"div",
|
|
137
138
|
{
|
|
138
|
-
className:
|
|
139
|
+
className: F(
|
|
139
140
|
s["iframe-button"],
|
|
140
|
-
|
|
141
|
+
r && s["with-icon"],
|
|
141
142
|
a && s["full-width"],
|
|
142
|
-
u &&
|
|
143
|
+
u && V[u]
|
|
143
144
|
),
|
|
144
145
|
"data-part": "iframe-button",
|
|
145
146
|
children: [
|
|
146
|
-
/* @__PURE__ */
|
|
147
|
-
e && /* @__PURE__ */
|
|
148
|
-
/* @__PURE__ */
|
|
147
|
+
/* @__PURE__ */ B("span", { className: s.label, children: t }),
|
|
148
|
+
e && /* @__PURE__ */ B(W, { className: F(s["loading-skeleton"]) }),
|
|
149
|
+
/* @__PURE__ */ B(
|
|
149
150
|
"iframe",
|
|
150
151
|
{
|
|
151
152
|
ref: d,
|
|
152
|
-
className:
|
|
153
|
-
...
|
|
153
|
+
className: F(s.iframe, e ? s.hidden : void 0, o),
|
|
154
|
+
...l
|
|
154
155
|
}
|
|
155
156
|
),
|
|
156
|
-
!
|
|
157
|
+
!h && /* @__PURE__ */ B("div", { ref: p, className: s["computed-style"], children: /* @__PURE__ */ B("canvas", { ref: x }) })
|
|
157
158
|
]
|
|
158
159
|
}
|
|
159
160
|
);
|
|
160
161
|
}
|
|
161
162
|
);
|
|
162
|
-
|
|
163
|
+
D.displayName = "IframeButton";
|
|
163
164
|
export {
|
|
164
|
-
|
|
165
|
+
D as IframeButton
|
|
165
166
|
};
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "0.0.
|
|
1
|
+
export declare const VERSION = "0.0.73";
|
package/dist/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coinbase/cdp-react",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.73",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@internationalized/number": "3.6.4",
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
},
|
|
16
16
|
"peerDependencies": {
|
|
17
17
|
"react": ">=18.2.0 <19.2.0",
|
|
18
|
-
"@coinbase/cdp-core": "^0.0.
|
|
19
|
-
"@coinbase/cdp-hooks": "^0.0.
|
|
18
|
+
"@coinbase/cdp-core": "^0.0.73",
|
|
19
|
+
"@coinbase/cdp-hooks": "^0.0.73"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"@size-limit/preset-big-lib": "^11.2.0",
|
|
@@ -47,8 +47,8 @@
|
|
|
47
47
|
"vite": "^7.0.4",
|
|
48
48
|
"vite-plugin-dts": "^4.5.4",
|
|
49
49
|
"vite-plugin-lib-inject-css": "^2.2.2",
|
|
50
|
-
"@coinbase/cdp-
|
|
51
|
-
"@coinbase/cdp-
|
|
50
|
+
"@coinbase/cdp-core": "^0.0.73",
|
|
51
|
+
"@coinbase/cdp-hooks": "^0.0.73"
|
|
52
52
|
},
|
|
53
53
|
"size-limit": [
|
|
54
54
|
{
|