@gearbox-protocol/ui-kit 4.0.1 → 4.1.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.
Files changed (36) hide show
  1. package/dist/cjs/components/base/review-button/review-button.cjs +1 -1
  2. package/dist/cjs/components/base/segmented-tabs/segmented-tabs.cjs +1 -1
  3. package/dist/cjs/components/buttons/button/button.variants.cjs +1 -1
  4. package/dist/cjs/components/buttons/tab-button/tab-button.cjs +1 -1
  5. package/dist/cjs/components/client-adapters/index.cjs +1 -1
  6. package/dist/cjs/components/graph/default-config.cjs +1 -1
  7. package/dist/cjs/components/index.cjs +1 -1
  8. package/dist/cjs/components/rounded-image/rounded-image.cjs +1 -1
  9. package/dist/cjs/components/token-icon/token-icon-source.cjs +1 -1
  10. package/dist/cjs/components/token-icon/token-icon.cjs +1 -1
  11. package/dist/cjs/index.cjs +1 -1
  12. package/dist/esm/components/base/review-button/review-button.js +19 -25
  13. package/dist/esm/components/base/segmented-tabs/segmented-tabs.js +7 -6
  14. package/dist/esm/components/buttons/button/button.variants.js +5 -5
  15. package/dist/esm/components/buttons/tab-button/tab-button.js +12 -9
  16. package/dist/esm/components/client-adapters/index.js +2 -4
  17. package/dist/esm/components/graph/default-config.js +20 -20
  18. package/dist/esm/components/index.js +279 -281
  19. package/dist/esm/components/navbar-logo/navbar-logo.js +10 -13
  20. package/dist/esm/components/rounded-image/rounded-image.js +42 -45
  21. package/dist/esm/components/token-icon/token-icon-source.js +51 -44
  22. package/dist/esm/components/token-icon/token-icon.js +28 -136
  23. package/dist/esm/index.js +327 -329
  24. package/dist/globals.css +1 -1
  25. package/dist/types/components/client-adapters/index.d.ts +0 -1
  26. package/dist/types/components/token-icon/token-icon-source.d.ts +4 -42
  27. package/dist/types/components/token-icon/token-icon.d.ts +6 -17
  28. package/dist/types/components/token-symbol/token-symbol.d.ts +1 -1
  29. package/dist/types/types/common.d.ts +1 -1
  30. package/package.json +1 -1
  31. package/dist/cjs/components/client-adapters/styled-button/index.cjs +0 -1
  32. package/dist/cjs/components/client-adapters/styled-button/styled-button.cjs +0 -1
  33. package/dist/esm/components/client-adapters/styled-button/index.js +0 -4
  34. package/dist/esm/components/client-adapters/styled-button/styled-button.js +0 -29
  35. package/dist/types/components/client-adapters/styled-button/index.d.ts +0 -1
  36. package/dist/types/components/client-adapters/styled-button/styled-button.d.ts +0 -18
@@ -9,19 +9,16 @@ function p({
9
9
  ...n
10
10
  }) {
11
11
  const r = o ? { width: o, height: o } : {};
12
- return (
13
- // biome-ignore lint/performance/noImgElement: Universal component that works outside Next.js
14
- /* @__PURE__ */ a(
15
- "img",
16
- {
17
- alt: "Logo",
18
- className: c("object-contain", t),
19
- style: { ...r, ...i },
20
- loading: "lazy",
21
- decoding: "async",
22
- ...n
23
- }
24
- )
12
+ return /* @__PURE__ */ a(
13
+ "img",
14
+ {
15
+ alt: "Logo",
16
+ className: c("object-contain", t),
17
+ style: { ...r, ...i },
18
+ loading: "lazy",
19
+ decoding: "async",
20
+ ...n
21
+ }
25
22
  );
26
23
  }
27
24
  export {
@@ -1,15 +1,15 @@
1
- import { jsx as E } from "react/jsx-runtime";
2
- import * as k from "react";
3
- import { useState as i, useRef as l, useEffect as w } from "react";
4
- import { cn as N } from "../../utils/cn.js";
1
+ import { jsx as I } from "react/jsx-runtime";
2
+ import * as w from "react";
3
+ import { useState as i, useRef as f, useEffect as N } from "react";
4
+ import { cn as k } from "../../utils/cn.js";
5
5
  import "@gearbox-protocol/sdk/onchain";
6
6
  import "../../utils/z-index.js";
7
- import { getStatic as T } from "../../utils/internal/static.js";
8
- const u = T("/tokens/default.svg"), m = /* @__PURE__ */ new Map();
9
- function f(t) {
7
+ import { getStatic as x } from "../../utils/internal/static.js";
8
+ const u = x("/tokens/default.svg"), m = /* @__PURE__ */ new Map();
9
+ function l(t) {
10
10
  return m.get(t) ? u : t;
11
11
  }
12
- const U = k.forwardRef(
12
+ const C = w.forwardRef(
13
13
  ({
14
14
  className: t,
15
15
  size: c,
@@ -20,49 +20,46 @@ const U = k.forwardRef(
20
20
  fit: R = "cover",
21
21
  ...y
22
22
  }, r) => {
23
- const [v, s] = i(void 0), [b, n] = i(!1), a = l(!1), d = l(null), I = (e) => {
24
- d.current = e, typeof r == "function" ? r(e) : r && (r.current = e), e?.complete && e.naturalWidth > 0 && n(!0);
23
+ const [v, s] = i(void 0), [b, a] = i(!1), n = f(!1), d = f(null), L = (e) => {
24
+ d.current = e, typeof r == "function" ? r(e) : r && (r.current = e), e?.complete && e.naturalWidth > 0 && a(!0);
25
25
  };
26
- w(() => {
27
- f(o), s(void 0), a.current = !1;
26
+ N(() => {
27
+ l(o), s(void 0), n.current = !1;
28
28
  const e = d.current;
29
- n(!!e?.complete && e.naturalWidth > 0);
29
+ a(!!e?.complete && e.naturalWidth > 0);
30
30
  }, [o]);
31
- const L = (e) => {
32
- a.current || (a.current = !0, m.set(e.currentTarget.src, !0), s(h));
33
- }, j = () => {
34
- n(!0);
31
+ const j = (e) => {
32
+ n.current || (n.current = !0, m.set(e.currentTarget.src, !0), s(h));
33
+ }, E = () => {
34
+ a(!0);
35
35
  };
36
- return (
37
- // biome-ignore lint/performance/noImgElement: Universal component that works outside Next.js
38
- /* @__PURE__ */ E(
39
- "img",
40
- {
41
- ref: I,
42
- src: v || f(o),
43
- alt: "",
44
- className: N(
45
- R === "cover" ? "object-cover" : "object-contain object-center",
46
- g && "rounded-full",
47
- !b && "bg-gray-90 dark:bg-gray-110 rounded-full",
48
- t
49
- ),
50
- style: {
51
- width: c,
52
- height: c,
53
- ...p
54
- },
55
- loading: "lazy",
56
- decoding: "async",
57
- onError: L,
58
- onLoad: j,
59
- ...y
60
- }
61
- )
36
+ return /* @__PURE__ */ I(
37
+ "img",
38
+ {
39
+ ref: L,
40
+ src: v || l(o),
41
+ alt: "",
42
+ className: k(
43
+ R === "cover" ? "object-cover" : "object-contain object-center",
44
+ g && "rounded-full",
45
+ !b && "bg-gray-90 dark:bg-gray-110 rounded-full",
46
+ t
47
+ ),
48
+ style: {
49
+ width: c,
50
+ height: c,
51
+ ...p
52
+ },
53
+ loading: "lazy",
54
+ decoding: "async",
55
+ onError: j,
56
+ onLoad: E,
57
+ ...y
58
+ }
62
59
  );
63
60
  }
64
61
  );
65
- U.displayName = "RoundedImage";
62
+ C.displayName = "RoundedImage";
66
63
  export {
67
- U as RoundedImage
64
+ C as RoundedImage
68
65
  };
@@ -1,48 +1,55 @@
1
- import { getStatic as s } from "../../utils/internal/static.js";
2
- const f = s("/tokens/templates/diesel.svg"), l = s("/logo/logo_symbol.png"), n = /V\d+$/, o = "_OLD", u = [
3
- { prefix: "farmd", requiresVersion: !1 },
4
- { prefix: "wd", requiresVersion: !1 },
5
- { prefix: "sd", requiresVersion: !0 },
6
- { prefix: "d", requiresVersion: !0 }
7
- ];
8
- function c(e) {
9
- for (const { prefix: i, requiresVersion: t } of u) {
10
- if (!e.startsWith(i)) continue;
11
- let r = e.slice(i.length);
12
- if (r.endsWith(o) && (r = r.slice(0, -o.length)), n.test(r))
13
- r = r.replace(n, "");
14
- else if (t)
15
- continue;
16
- if (r) return r;
17
- }
1
+ import { getStatic as d } from "../../utils/internal/static.js";
2
+ const r = d("/tokens/default.svg"), u = d("/logo/logo_symbol.png");
3
+ function e(t) {
4
+ return t.replaceAll("/", "").replaceAll(" ", "").toLowerCase();
18
5
  }
19
- function d(e) {
20
- return {
21
- kind: "composite",
22
- preset: "centered_foreground",
23
- scaleFactor: 0.74,
24
- layers: [
25
- {
26
- type: "url",
27
- url: f
28
- },
29
- {
30
- type: "symbol",
31
- symbol: e
32
- }
33
- ]
34
- };
35
- }
36
- function g(e) {
37
- if (e === void 0) return;
38
- const i = typeof e == "string" ? e : e.symbol;
39
- if (!i) return;
40
- if (i === "GEAR")
41
- return { icon: l };
42
- const t = c(i);
43
- return t ? d(t) : i;
6
+ const w = {
7
+ // Curve factory pools, on the base pool's icon.
8
+ "crvusdfrax-f": "crvusdfrax",
9
+ "crvusdusdc-f": "crvusdusdc",
10
+ "crvusdusdt-f": "crvusdusdt",
11
+ "cvxcrvusdfrax-f": "cvxcrvusdfrax",
12
+ "cvxcrvusdusdc-f": "cvxcrvusdusdc",
13
+ "cvxcrvusdusdt-f": "cvxcrvusdusdt",
14
+ "stkcvxcrvusdfrax-f": "stkcvxcrvusdfrax",
15
+ "stkcvxcrvusdusdc-f": "stkcvxcrvusdusdc",
16
+ "stkcvxcrvusdusdt-f": "stkcvxcrvusdusdt",
17
+ // Mellow withdrawal phantoms. The SDK reports all of them as one `wdwstETH`;
18
+ // only the backend tells the vaults apart, and the icon never did.
19
+ "wdwsteth[cp0xlrt]": "wdwsteth",
20
+ "wdwsteth[pzeth]": "wdwsteth",
21
+ "wdwsteth[re7lrt]": "wdwsteth",
22
+ "wdwsteth[rsteth]": "wdwsteth",
23
+ "wdwsteth[steaklrt]": "wdwsteth",
24
+ // Withdrawal phantoms of a single asset.
25
+ wdiusd: "iusd",
26
+ wdrseth: "rseth",
27
+ // Curator variants of a pool share token.
28
+ "dwbtc-v3-0": "dwbtcv3",
29
+ "dwethv3-cp0x": "dwethv3",
30
+ // Wrappers and staked versions, on the asset they hold.
31
+ fweth: "weth",
32
+ fwsteth: "wsteth",
33
+ kpkfrxusd: "frxusd",
34
+ kpkweth: "weth",
35
+ kpkwsteth: "wsteth",
36
+ stkrlusdusdc: "rlusdusdc",
37
+ syusd: "yusd",
38
+ xtz: "wxtz",
39
+ // Curated vaults, on their underlying.
40
+ "cyb-cbbtc": "cbbtc",
41
+ "cyb-tbtc": "tbtc",
42
+ "cyb-wbtc": "wbtc",
43
+ re7tbtc: "tbtc",
44
+ re7usdc: "usdc"
45
+ };
46
+ function f(t) {
47
+ const s = typeof t == "string" ? t : t?.symbol;
48
+ if (!s) return r;
49
+ if (s === "GEAR") return u;
50
+ const c = e(s);
51
+ return c ? d(`/tokens/${w[c] ?? c}.svg`) : r;
44
52
  }
45
53
  export {
46
- g as getTokenIcon,
47
- c as parseShareTokenUnderlying
54
+ f as getTokenIconUrl
48
55
  };
@@ -1,143 +1,35 @@
1
- import { jsx as r, jsxs as x, Fragment as R } from "react/jsx-runtime";
2
- import b from "react";
3
- import { getTokenIcon as I } from "./token-icon-source.js";
4
- import { cn as y } from "../../utils/cn.js";
5
- import "@gearbox-protocol/sdk/onchain";
6
- import "../../utils/z-index.js";
7
- import { getStatic as k } from "../../utils/internal/static.js";
8
- import { RoundedImage as m } from "../rounded-image/rounded-image.js";
9
- const u = k("/tokens/default.svg");
10
- function w(t) {
11
- return t.replace("/", "").replace(" ", "").replace("-f", "").replace("-", "_").toLowerCase();
12
- }
13
- function _(t) {
14
- return typeof t == "object" && t !== null && "icon" in t && !("kind" in t);
15
- }
16
- function N(t) {
17
- return typeof t == "object" && t !== null && "kind" in t && t.kind === "composite";
18
- }
19
- function T(t) {
20
- if (t.type === "url") return t.url;
21
- const e = w(t.symbol);
22
- return e ? k(`/tokens/${e}.svg`) : u;
23
- }
24
- function j(t) {
25
- if (!t || N(t))
26
- return u;
27
- if (_(t))
28
- return t.icon;
29
- const e = w(t);
30
- return e ? k(`/tokens/${e}.svg`) : u;
31
- }
32
- const F = 0.65;
33
- function L(t, e) {
34
- return t !== void 0 ? I(t) : typeof e == "string" ? I(e) : e;
35
- }
36
- const v = b.forwardRef(function({
37
- token: e,
38
- symbol: n,
39
- size: o = 48,
40
- fit: c = "contain",
41
- rounded: s = !1,
42
- className: a,
43
- ...l
44
- }, f) {
45
- const i = L(e, n);
46
- if (N(i))
47
- return /* @__PURE__ */ r(
48
- C,
1
+ import { jsx as f } from "react/jsx-runtime";
2
+ import i from "react";
3
+ import { getTokenIconUrl as d } from "./token-icon-source.js";
4
+ import { RoundedImage as p } from "../rounded-image/rounded-image.js";
5
+ const l = i.forwardRef(
6
+ function({
7
+ token: n,
8
+ symbol: r,
9
+ size: o = 48,
10
+ fit: t = "contain",
11
+ rounded: e = !1,
12
+ className: m,
13
+ ...a
14
+ }, c) {
15
+ return /* @__PURE__ */ f(
16
+ p,
49
17
  {
50
- ref: f,
51
- composite: i,
18
+ ref: c,
19
+ className: m,
20
+ src: d(n ?? r),
21
+ alt: "",
22
+ rounded: e,
23
+ fit: t,
24
+ width: o,
25
+ height: o,
52
26
  size: o,
53
- fit: c,
54
- rounded: s,
55
- className: a
27
+ ...a
56
28
  }
57
29
  );
58
- const p = j(i);
59
- return /* @__PURE__ */ r(
60
- m,
61
- {
62
- ref: f,
63
- className: a,
64
- src: p,
65
- alt: "",
66
- rounded: s,
67
- fit: c,
68
- width: o,
69
- height: o,
70
- size: o,
71
- ...l
72
- }
73
- );
74
- }), C = b.forwardRef(function({ composite: e, size: n, fit: o, rounded: c, className: s }, a) {
75
- const { preset: l, layers: f, scaleFactor: i = F } = e, [p, S] = f, g = T(p), U = T(S), d = Math.round(n * i);
76
- let h;
77
- switch (l) {
78
- case "centered_foreground":
79
- h = /* @__PURE__ */ x(R, { children: [
80
- /* @__PURE__ */ r(
81
- m,
82
- {
83
- className: "absolute inset-0",
84
- style: { zIndex: 0 },
85
- src: g,
86
- alt: "background",
87
- rounded: c,
88
- fit: o,
89
- size: n
90
- }
91
- ),
92
- /* @__PURE__ */ r(
93
- "div",
94
- {
95
- className: y(
96
- "absolute left-1/2 top-1/2 z-[1] -translate-x-1/2 -translate-y-1/2",
97
- "flex items-center justify-center"
98
- ),
99
- style: {
100
- width: d,
101
- height: d
102
- },
103
- children: /* @__PURE__ */ r(
104
- m,
105
- {
106
- src: U,
107
- alt: "foreground",
108
- rounded: c,
109
- fit: o,
110
- size: d
111
- }
112
- )
113
- }
114
- )
115
- ] });
116
- break;
117
- default:
118
- return console.error("Unknown TokenIcon composite preset", l), /* @__PURE__ */ r(
119
- m,
120
- {
121
- src: g,
122
- alt: "error",
123
- rounded: c,
124
- fit: o,
125
- size: n
126
- }
127
- );
128
30
  }
129
- return /* @__PURE__ */ r(
130
- "div",
131
- {
132
- ref: a,
133
- className: y("relative inline-block shrink-0", s),
134
- style: { width: n, height: n },
135
- children: h
136
- }
137
- );
138
- });
139
- C.displayName = "TokenIconComposite";
140
- v.displayName = "TokenIcon";
31
+ );
32
+ l.displayName = "TokenIcon";
141
33
  export {
142
- v as TokenIcon
34
+ l as TokenIcon
143
35
  };