@gearbox-protocol/ui-kit 3.13.0-next.1 → 3.13.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/dist/cjs/components/compound-apy/compound-apy.cjs +1 -1
- package/dist/cjs/components/layout/main-aside-layout/main-aside-layout.cjs +1 -1
- package/dist/cjs/components/rounded-image/rounded-image.cjs +1 -1
- package/dist/cjs/components/token-icon/token-icon.cjs +1 -1
- package/dist/cjs/components/token-symbol/token-symbol.cjs +1 -1
- package/dist/cjs/types/common.cjs +1 -1
- package/dist/esm/components/compound-apy/compound-apy.js +71 -68
- package/dist/esm/components/layout/main-aside-layout/main-aside-layout.js +22 -70
- package/dist/esm/components/rounded-image/rounded-image.js +16 -16
- package/dist/esm/components/token-icon/token-icon.js +134 -44
- package/dist/esm/components/token-symbol/token-symbol.js +55 -46
- package/dist/esm/types/common.js +6 -1
- package/dist/globals.css +1 -1
- package/dist/types/components/compound-apy/compound-apy.d.ts +1 -3
- package/dist/types/components/help-tip/help-tip.d.ts +2 -2
- package/dist/types/components/layout/main-aside-layout/main-aside-layout.d.ts +5 -46
- package/dist/types/components/token-icon/index.d.ts +1 -1
- package/dist/types/components/token-icon/token-icon.d.ts +8 -3
- package/dist/types/types/common.d.ts +11 -1
- package/package.json +4 -4
- package/src/styles/base.css +2 -4
|
@@ -1,53 +1,143 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { jsx as r, jsxs as S, Fragment as _ } from "react/jsx-runtime";
|
|
2
|
+
import w from "react";
|
|
3
|
+
import "@gearbox-protocol/sdk";
|
|
4
|
+
import { cn as I } from "../../utils/cn.js";
|
|
5
|
+
import "sonner";
|
|
6
|
+
import "@gearbox-protocol/sdk/common-utils";
|
|
7
|
+
import { getStatic as d } from "../../utils/static.js";
|
|
8
|
+
import "luxon";
|
|
9
|
+
import "../../utils/z-index.js";
|
|
10
|
+
import { RoundedImage as l } from "../rounded-image/rounded-image.js";
|
|
11
|
+
const s = d("/tokens/default.svg");
|
|
12
|
+
function T(t) {
|
|
13
|
+
return t.replace("/", "").replace(" ", "").replace("-f", "").replace("-", "_").toLowerCase();
|
|
8
14
|
}
|
|
9
|
-
function
|
|
10
|
-
|
|
11
|
-
if (typeof e == "object" && e !== null && "icon" in e)
|
|
12
|
-
return e.icon;
|
|
13
|
-
const n = d(e);
|
|
14
|
-
return n ? c(`/tokens/${n}.svg`) : r;
|
|
15
|
+
function j(t) {
|
|
16
|
+
return typeof t == "object" && t !== null && "icon" in t && !("kind" in t);
|
|
15
17
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
return
|
|
27
|
-
|
|
18
|
+
function k(t) {
|
|
19
|
+
return typeof t == "object" && t !== null && "kind" in t && t.kind === "composite";
|
|
20
|
+
}
|
|
21
|
+
function u(t) {
|
|
22
|
+
if (t.type === "url") return t.url;
|
|
23
|
+
const o = T(t.symbol);
|
|
24
|
+
return o ? d(`/tokens/${o}.svg`) : s;
|
|
25
|
+
}
|
|
26
|
+
function y(t) {
|
|
27
|
+
if (!t || k(t))
|
|
28
|
+
return s;
|
|
29
|
+
if (j(t))
|
|
30
|
+
return t.icon;
|
|
31
|
+
const o = T(t);
|
|
32
|
+
return o ? d(`/tokens/${o}.svg`) : s;
|
|
33
|
+
}
|
|
34
|
+
function F(t) {
|
|
35
|
+
return t ? k(t) ? t.layers.map(u) : [y(t)] : [s];
|
|
36
|
+
}
|
|
37
|
+
const b = 0.65, L = w.forwardRef(function({ symbol: o, size: e = 48, fit: n = "contain", rounded: c = !1, className: a, ...f }, i) {
|
|
38
|
+
if (k(o))
|
|
39
|
+
return /* @__PURE__ */ r(
|
|
40
|
+
N,
|
|
28
41
|
{
|
|
29
|
-
ref:
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
rounded:
|
|
34
|
-
|
|
35
|
-
width: n,
|
|
36
|
-
height: n,
|
|
37
|
-
size: n,
|
|
38
|
-
...i
|
|
42
|
+
ref: i,
|
|
43
|
+
composite: o,
|
|
44
|
+
size: e,
|
|
45
|
+
fit: n,
|
|
46
|
+
rounded: c,
|
|
47
|
+
className: a
|
|
39
48
|
}
|
|
40
49
|
);
|
|
50
|
+
const p = y(o);
|
|
51
|
+
return /* @__PURE__ */ r(
|
|
52
|
+
l,
|
|
53
|
+
{
|
|
54
|
+
ref: i,
|
|
55
|
+
className: a,
|
|
56
|
+
src: p,
|
|
57
|
+
alt: "",
|
|
58
|
+
rounded: c,
|
|
59
|
+
fit: n,
|
|
60
|
+
width: e,
|
|
61
|
+
height: e,
|
|
62
|
+
size: e,
|
|
63
|
+
...f
|
|
64
|
+
}
|
|
65
|
+
);
|
|
66
|
+
}), N = w.forwardRef(function({ composite: o, size: e, fit: n, rounded: c, className: a }, f) {
|
|
67
|
+
const { preset: i, layers: p, scaleFactor: U = b } = o, [C, x] = p, g = u(C), R = u(x), m = Math.round(e * U);
|
|
68
|
+
let h;
|
|
69
|
+
switch (i) {
|
|
70
|
+
case "centered_foreground":
|
|
71
|
+
h = /* @__PURE__ */ S(_, { children: [
|
|
72
|
+
/* @__PURE__ */ r(
|
|
73
|
+
l,
|
|
74
|
+
{
|
|
75
|
+
className: "absolute inset-0",
|
|
76
|
+
style: { zIndex: 0 },
|
|
77
|
+
src: g,
|
|
78
|
+
alt: "background",
|
|
79
|
+
rounded: c,
|
|
80
|
+
fit: n,
|
|
81
|
+
size: e
|
|
82
|
+
}
|
|
83
|
+
),
|
|
84
|
+
/* @__PURE__ */ r(
|
|
85
|
+
"div",
|
|
86
|
+
{
|
|
87
|
+
className: I(
|
|
88
|
+
"absolute left-1/2 top-1/2 z-[1] -translate-x-1/2 -translate-y-1/2",
|
|
89
|
+
"flex items-center justify-center"
|
|
90
|
+
),
|
|
91
|
+
style: {
|
|
92
|
+
width: m,
|
|
93
|
+
height: m
|
|
94
|
+
},
|
|
95
|
+
children: /* @__PURE__ */ r(
|
|
96
|
+
l,
|
|
97
|
+
{
|
|
98
|
+
src: R,
|
|
99
|
+
alt: "foreground",
|
|
100
|
+
rounded: c,
|
|
101
|
+
fit: n,
|
|
102
|
+
size: m
|
|
103
|
+
}
|
|
104
|
+
)
|
|
105
|
+
}
|
|
106
|
+
)
|
|
107
|
+
] });
|
|
108
|
+
break;
|
|
109
|
+
default:
|
|
110
|
+
return console.error("Unknown TokenIcon composite preset", i), /* @__PURE__ */ r(
|
|
111
|
+
l,
|
|
112
|
+
{
|
|
113
|
+
src: g,
|
|
114
|
+
alt: "error",
|
|
115
|
+
rounded: c,
|
|
116
|
+
fit: n,
|
|
117
|
+
size: e
|
|
118
|
+
}
|
|
119
|
+
);
|
|
41
120
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
121
|
+
return /* @__PURE__ */ r(
|
|
122
|
+
"div",
|
|
123
|
+
{
|
|
124
|
+
ref: f,
|
|
125
|
+
className: I("relative inline-block shrink-0", a),
|
|
126
|
+
style: { width: e, height: e },
|
|
127
|
+
children: h
|
|
128
|
+
}
|
|
129
|
+
);
|
|
130
|
+
});
|
|
131
|
+
N.displayName = "TokenIconComposite";
|
|
132
|
+
L.displayName = "TokenIcon";
|
|
133
|
+
function B(t) {
|
|
134
|
+
for (const o of t)
|
|
135
|
+
for (const e of F(o)) {
|
|
136
|
+
const n = new window.Image();
|
|
137
|
+
n.src = e;
|
|
138
|
+
}
|
|
49
139
|
}
|
|
50
140
|
export {
|
|
51
|
-
|
|
52
|
-
|
|
141
|
+
L as TokenIcon,
|
|
142
|
+
B as preloadTokenIcons
|
|
53
143
|
};
|
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
import { jsxs as t, jsx as
|
|
2
|
-
import { cva as
|
|
3
|
-
import
|
|
4
|
-
import { RoundedImage as
|
|
1
|
+
import { jsxs as t, jsx as i } from "react/jsx-runtime";
|
|
2
|
+
import { cva as y } from "class-variance-authority";
|
|
3
|
+
import N from "react";
|
|
4
|
+
import { RoundedImage as x } from "../rounded-image/rounded-image.js";
|
|
5
5
|
import { ShortString as S } from "../short-string/short-string.js";
|
|
6
|
-
import { TokenIcon as
|
|
7
|
-
import { SimpleTooltip as
|
|
6
|
+
import { TokenIcon as l } from "../token-icon/token-icon.js";
|
|
7
|
+
import { SimpleTooltip as I } from "../tooltip/simple-tooltip.js";
|
|
8
8
|
import "../tooltip/tooltip.js";
|
|
9
|
+
import { isIconComposite as b } from "../../types/common.js";
|
|
9
10
|
import "@gearbox-protocol/sdk";
|
|
10
|
-
import { cn as
|
|
11
|
+
import { cn as T } from "../../utils/cn.js";
|
|
11
12
|
import "sonner";
|
|
12
13
|
import "@gearbox-protocol/sdk/common-utils";
|
|
13
|
-
import { getNetworkIcon as
|
|
14
|
+
import { getNetworkIcon as R } from "../../utils/network-icons.js";
|
|
14
15
|
import "luxon";
|
|
15
16
|
import "../../utils/z-index.js";
|
|
16
|
-
const
|
|
17
|
+
const _ = y("", {
|
|
17
18
|
variants: {
|
|
18
19
|
marginSize: {
|
|
19
20
|
sm: "gap-1",
|
|
@@ -25,52 +26,60 @@ const R = N("", {
|
|
|
25
26
|
marginSize: "md"
|
|
26
27
|
}
|
|
27
28
|
});
|
|
28
|
-
function _(r) {
|
|
29
|
-
if (r)
|
|
30
|
-
return typeof r == "string" ? r : r.icon ? { icon: r.icon } : r.symbol;
|
|
31
|
-
}
|
|
32
29
|
function j(r) {
|
|
30
|
+
if (r) {
|
|
31
|
+
if (typeof r == "string") return r;
|
|
32
|
+
if (r.icon !== void 0) {
|
|
33
|
+
if (typeof r.icon == "string")
|
|
34
|
+
return { icon: r.icon };
|
|
35
|
+
if (b(r.icon))
|
|
36
|
+
return r.icon;
|
|
37
|
+
}
|
|
38
|
+
return r.symbol;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function z(r) {
|
|
33
42
|
if (r)
|
|
34
43
|
return typeof r == "string" ? r : r.title;
|
|
35
44
|
}
|
|
36
|
-
const
|
|
45
|
+
const V = N.forwardRef(
|
|
37
46
|
({
|
|
38
47
|
className: r,
|
|
39
48
|
marginSize: d = "lg",
|
|
40
|
-
token:
|
|
41
|
-
title:
|
|
42
|
-
size:
|
|
49
|
+
token: n,
|
|
50
|
+
title: m,
|
|
51
|
+
size: s = 24,
|
|
43
52
|
showSymbol: f = !1,
|
|
44
53
|
showIcon: p = !0,
|
|
45
|
-
maxLength:
|
|
46
|
-
chainId:
|
|
47
|
-
comment:
|
|
48
|
-
network:
|
|
49
|
-
...
|
|
54
|
+
maxLength: u,
|
|
55
|
+
chainId: C,
|
|
56
|
+
comment: c,
|
|
57
|
+
network: e,
|
|
58
|
+
...g
|
|
50
59
|
}, h) => {
|
|
51
|
-
const o =
|
|
52
|
-
/* @__PURE__ */
|
|
53
|
-
|
|
60
|
+
const o = j(n), v = m || z(n), a = () => e ? /* @__PURE__ */ t("div", { className: "relative", children: [
|
|
61
|
+
/* @__PURE__ */ i(
|
|
62
|
+
l,
|
|
54
63
|
{
|
|
55
64
|
symbol: o,
|
|
56
|
-
size:
|
|
65
|
+
size: s,
|
|
57
66
|
className: "shrink-0 self-center"
|
|
58
67
|
}
|
|
59
68
|
),
|
|
60
|
-
/* @__PURE__ */
|
|
61
|
-
|
|
69
|
+
/* @__PURE__ */ i("div", { className: "absolute -top-[10px] -right-[7px]", children: /* @__PURE__ */ i(
|
|
70
|
+
x,
|
|
62
71
|
{
|
|
63
|
-
src:
|
|
64
|
-
alt:
|
|
72
|
+
src: R(e),
|
|
73
|
+
alt: e,
|
|
65
74
|
size: 14,
|
|
66
75
|
rounded: !0
|
|
67
76
|
}
|
|
68
77
|
) })
|
|
69
|
-
] }) : /* @__PURE__ */
|
|
70
|
-
|
|
78
|
+
] }) : /* @__PURE__ */ i(
|
|
79
|
+
l,
|
|
71
80
|
{
|
|
72
81
|
symbol: o,
|
|
73
|
-
size:
|
|
82
|
+
size: s,
|
|
74
83
|
className: "shrink-0 self-center"
|
|
75
84
|
}
|
|
76
85
|
);
|
|
@@ -78,22 +87,22 @@ const z = x.forwardRef(
|
|
|
78
87
|
"div",
|
|
79
88
|
{
|
|
80
89
|
ref: h,
|
|
81
|
-
className:
|
|
90
|
+
className: T(
|
|
82
91
|
"flex items-center",
|
|
83
|
-
|
|
92
|
+
_({ marginSize: d }),
|
|
84
93
|
r
|
|
85
94
|
),
|
|
86
|
-
...
|
|
95
|
+
...g,
|
|
87
96
|
children: [
|
|
88
|
-
p && o && (
|
|
97
|
+
p && o && (e !== void 0 ? /* @__PURE__ */ t(I, { title: a(), children: [
|
|
89
98
|
"Network: ",
|
|
90
|
-
|
|
91
|
-
] }) :
|
|
92
|
-
(
|
|
93
|
-
/* @__PURE__ */
|
|
94
|
-
|
|
99
|
+
e
|
|
100
|
+
] }) : a()),
|
|
101
|
+
(m || f) && /* @__PURE__ */ t("div", { className: "flex items-center gap-1 self-center", children: [
|
|
102
|
+
/* @__PURE__ */ i("div", { children: /* @__PURE__ */ i(S, { maxLength: u, children: v }) }),
|
|
103
|
+
c && /* @__PURE__ */ t("div", { className: "text-md text-muted-foreground leading-tight", children: [
|
|
95
104
|
"(",
|
|
96
|
-
|
|
105
|
+
c,
|
|
97
106
|
")"
|
|
98
107
|
] })
|
|
99
108
|
] })
|
|
@@ -102,8 +111,8 @@ const z = x.forwardRef(
|
|
|
102
111
|
);
|
|
103
112
|
}
|
|
104
113
|
);
|
|
105
|
-
|
|
114
|
+
V.displayName = "TokenSymbol";
|
|
106
115
|
export {
|
|
107
|
-
|
|
108
|
-
|
|
116
|
+
V as TokenSymbol,
|
|
117
|
+
j as getSymbolOrIcon
|
|
109
118
|
};
|