@gearbox-protocol/ui-kit 4.0.0-next.84 → 4.0.0-next.85
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/rounded-image/rounded-image.cjs +1 -1
- package/dist/cjs/components/token-icon/token-icon-source.cjs +1 -1
- package/dist/cjs/components/token-icon/token-icon.cjs +1 -1
- package/dist/esm/components/rounded-image/rounded-image.js +25 -25
- package/dist/esm/components/token-icon/token-icon-source.js +23 -8
- package/dist/esm/components/token-icon/token-icon.js +26 -45
- package/dist/types/components/token-icon/token-icon-source.d.ts +4 -8
- package/dist/types/components/token-icon/token-icon.d.ts +4 -12
- package/dist/types/components/token-symbol/token-symbol.d.ts +1 -1
- package/dist/types/types/common.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const q=require("react/jsx-runtime"),c=require("react"),I=require("../../utils/cn.cjs");require("@gearbox-protocol/sdk/onchain");require("../../utils/z-index.cjs");const L=require("../../utils/internal/static.cjs");function S(e){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const q=require("react/jsx-runtime"),c=require("react"),I=require("../../utils/cn.cjs");require("@gearbox-protocol/sdk/onchain");require("../../utils/z-index.cjs");const L=require("../../utils/internal/static.cjs");function S(e){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const a=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(r,n,a.get?a:{enumerable:!0,get:()=>e[n]})}}return r.default=e,Object.freeze(r)}const w=S(c),g=L.getStatic("/tokens/default.svg"),m=new Map;function f(e){return m.get(e)?g:e}const b=w.forwardRef(({className:e,size:r,rounded:n=!0,style:a,src:s,defaultIcon:p=g,fit:y="cover",...R},o)=>{const[j,l]=c.useState(void 0),[h,u]=c.useState(!1),i=c.useRef(!1),d=c.useRef(null),v=t=>{d.current=t,typeof o=="function"?o(t):o&&(o.current=t),t?.complete&&t.naturalWidth>0&&u(!0)};c.useEffect(()=>{f(s),l(void 0),i.current=!1;const t=d.current;u(!!t?.complete&&t.naturalWidth>0)},[s]);const O=t=>{i.current||(i.current=!0,m.set(t.currentTarget.src,!0),l(p))},_=()=>{u(!0)};return q.jsx("img",{ref:v,src:j||f(s),alt:"",className:I.cn(y==="cover"?"object-cover":"object-contain object-center",n&&"rounded-full",!h&&"bg-gray-90 dark:bg-gray-110 rounded-full",e),style:{width:r,height:r,...a},loading:"lazy",decoding:"async",onError:O,onLoad:_,...R})});b.displayName="RoundedImage";exports.RoundedImage=b;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("../../utils/internal/static.cjs"),u=r.getStatic("/tokens/default.svg"),d=r.getStatic("/logo/logo_symbol.png");function e(s){return s.replaceAll("/","").replaceAll(" ","").toLowerCase()}const v={"crvusdfrax-f":"crvusdfrax","crvusdusdc-f":"crvusdusdc","crvusdusdt-f":"crvusdusdt","cvxcrvusdfrax-f":"cvxcrvusdfrax","cvxcrvusdusdc-f":"cvxcrvusdusdc","cvxcrvusdusdt-f":"cvxcrvusdusdt","stkcvxcrvusdfrax-f":"stkcvxcrvusdfrax","stkcvxcrvusdusdc-f":"stkcvxcrvusdusdc","stkcvxcrvusdusdt-f":"stkcvxcrvusdusdt"};function o(s){const c=typeof s=="string"?s:s?.symbol;if(!c)return u;if(c==="GEAR")return d;const t=e(c);return t?r.getStatic(`/tokens/${v[t]??t}.svg`):u}exports.getTokenIconUrl=o;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("react/jsx-runtime"),i=require("react"),I=require("./token-icon-source.cjs"),m=require("../rounded-image/rounded-image.cjs"),n=i.forwardRef(function({token:o,symbol:t,size:e=48,fit:c="contain",rounded:r=!1,className:u,...a},s){return d.jsx(m.RoundedImage,{ref:s,className:u,src:I.getTokenIconUrl(o??t),alt:"",rounded:r,fit:c,width:e,height:e,size:e,...a})});n.displayName="TokenIcon";exports.TokenIcon=n;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import * as
|
|
3
|
-
import { useState as i, useRef as
|
|
4
|
-
import { cn as
|
|
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
|
|
8
|
-
const u =
|
|
9
|
-
function
|
|
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
|
|
12
|
+
const C = w.forwardRef(
|
|
13
13
|
({
|
|
14
14
|
className: t,
|
|
15
15
|
size: c,
|
|
@@ -20,26 +20,26 @@ const U = k.forwardRef(
|
|
|
20
20
|
fit: R = "cover",
|
|
21
21
|
...y
|
|
22
22
|
}, r) => {
|
|
23
|
-
const [v, s] = i(void 0), [b,
|
|
24
|
-
d.current = e, typeof r == "function" ? r(e) : r && (r.current = e), e?.complete && e.naturalWidth > 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
|
-
|
|
27
|
-
|
|
26
|
+
N(() => {
|
|
27
|
+
l(o), s(void 0), n.current = !1;
|
|
28
28
|
const e = d.current;
|
|
29
|
-
|
|
29
|
+
a(!!e?.complete && e.naturalWidth > 0);
|
|
30
30
|
}, [o]);
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
},
|
|
34
|
-
|
|
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 /* @__PURE__ */
|
|
36
|
+
return /* @__PURE__ */ I(
|
|
37
37
|
"img",
|
|
38
38
|
{
|
|
39
|
-
ref:
|
|
40
|
-
src: v ||
|
|
39
|
+
ref: L,
|
|
40
|
+
src: v || l(o),
|
|
41
41
|
alt: "",
|
|
42
|
-
className:
|
|
42
|
+
className: k(
|
|
43
43
|
R === "cover" ? "object-cover" : "object-contain object-center",
|
|
44
44
|
g && "rounded-full",
|
|
45
45
|
!b && "bg-gray-90 dark:bg-gray-110 rounded-full",
|
|
@@ -52,14 +52,14 @@ const U = k.forwardRef(
|
|
|
52
52
|
},
|
|
53
53
|
loading: "lazy",
|
|
54
54
|
decoding: "async",
|
|
55
|
-
onError:
|
|
56
|
-
onLoad:
|
|
55
|
+
onError: j,
|
|
56
|
+
onLoad: E,
|
|
57
57
|
...y
|
|
58
58
|
}
|
|
59
59
|
);
|
|
60
60
|
}
|
|
61
61
|
);
|
|
62
|
-
|
|
62
|
+
C.displayName = "RoundedImage";
|
|
63
63
|
export {
|
|
64
|
-
|
|
64
|
+
C as RoundedImage
|
|
65
65
|
};
|
|
@@ -1,11 +1,26 @@
|
|
|
1
|
-
import { getStatic as
|
|
2
|
-
const
|
|
3
|
-
function
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { getStatic as u } from "../../utils/internal/static.js";
|
|
2
|
+
const t = u("/tokens/default.svg"), v = u("/logo/logo_symbol.png");
|
|
3
|
+
function d(s) {
|
|
4
|
+
return s.replaceAll("/", "").replaceAll(" ", "").toLowerCase();
|
|
5
|
+
}
|
|
6
|
+
const o = {
|
|
7
|
+
"crvusdfrax-f": "crvusdfrax",
|
|
8
|
+
"crvusdusdc-f": "crvusdusdc",
|
|
9
|
+
"crvusdusdt-f": "crvusdusdt",
|
|
10
|
+
"cvxcrvusdfrax-f": "cvxcrvusdfrax",
|
|
11
|
+
"cvxcrvusdusdc-f": "cvxcrvusdusdc",
|
|
12
|
+
"cvxcrvusdusdt-f": "cvxcrvusdusdt",
|
|
13
|
+
"stkcvxcrvusdfrax-f": "stkcvxcrvusdfrax",
|
|
14
|
+
"stkcvxcrvusdusdc-f": "stkcvxcrvusdusdc",
|
|
15
|
+
"stkcvxcrvusdusdt-f": "stkcvxcrvusdusdt"
|
|
16
|
+
};
|
|
17
|
+
function e(s) {
|
|
18
|
+
const c = typeof s == "string" ? s : s?.symbol;
|
|
19
|
+
if (!c) return t;
|
|
20
|
+
if (c === "GEAR") return v;
|
|
21
|
+
const r = d(c);
|
|
22
|
+
return r ? u(`/tokens/${o[r] ?? r}.svg`) : t;
|
|
8
23
|
}
|
|
9
24
|
export {
|
|
10
|
-
|
|
25
|
+
e as getTokenIconUrl
|
|
11
26
|
};
|
|
@@ -1,54 +1,35 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
const o = c("/tokens/default.svg");
|
|
7
|
-
function l(n) {
|
|
8
|
-
return n.replace("/", "").replace(" ", "").replace("-f", "").replace("-", "_").toLowerCase();
|
|
9
|
-
}
|
|
10
|
-
function k(n) {
|
|
11
|
-
return typeof n == "object" && n !== null && "icon" in n;
|
|
12
|
-
}
|
|
13
|
-
function T(n) {
|
|
14
|
-
if (!n) return o;
|
|
15
|
-
if (k(n))
|
|
16
|
-
return n.icon;
|
|
17
|
-
const e = l(n);
|
|
18
|
-
return e ? c(`/tokens/${e}.svg`) : o;
|
|
19
|
-
}
|
|
20
|
-
function _(n, e) {
|
|
21
|
-
return n !== void 0 ? t(n) : typeof e == "string" ? t(e) : e;
|
|
22
|
-
}
|
|
23
|
-
const h = I.forwardRef(
|
|
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(
|
|
24
6
|
function({
|
|
25
|
-
token:
|
|
26
|
-
symbol:
|
|
27
|
-
size:
|
|
28
|
-
fit:
|
|
29
|
-
rounded:
|
|
30
|
-
className:
|
|
31
|
-
...
|
|
32
|
-
},
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
d,
|
|
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,
|
|
36
17
|
{
|
|
37
|
-
ref:
|
|
38
|
-
className:
|
|
39
|
-
src:
|
|
18
|
+
ref: c,
|
|
19
|
+
className: m,
|
|
20
|
+
src: d(n ?? r),
|
|
40
21
|
alt: "",
|
|
41
|
-
rounded:
|
|
42
|
-
fit:
|
|
43
|
-
width:
|
|
44
|
-
height:
|
|
45
|
-
size:
|
|
46
|
-
...
|
|
22
|
+
rounded: e,
|
|
23
|
+
fit: t,
|
|
24
|
+
width: o,
|
|
25
|
+
height: o,
|
|
26
|
+
size: o,
|
|
27
|
+
...a
|
|
47
28
|
}
|
|
48
29
|
);
|
|
49
30
|
}
|
|
50
31
|
);
|
|
51
|
-
|
|
32
|
+
l.displayName = "TokenIcon";
|
|
52
33
|
export {
|
|
53
|
-
|
|
34
|
+
l as TokenIcon
|
|
54
35
|
};
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
/** Same shape as `TokenIcon`'s `symbol` prop — kept here to avoid a cycle. */
|
|
2
|
-
export type TokenIconSource = string | {
|
|
3
|
-
icon: string;
|
|
4
|
-
};
|
|
5
1
|
/**
|
|
6
2
|
* Everything the resolver needs from a token. Structural on purpose so the SDK
|
|
7
3
|
* read-model `Token`, the `TokenData` class, and bare metadata all fit without
|
|
@@ -11,8 +7,8 @@ export interface TokenIconInput {
|
|
|
11
7
|
symbol: string;
|
|
12
8
|
}
|
|
13
9
|
/**
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* `
|
|
10
|
+
* CDN asset for a token (or bare symbol). Every symbol maps to its own file —
|
|
11
|
+
* share tokens included, the CDN ships `dusdcv3.svg`, `sdwethv3.svg`,
|
|
12
|
+
* `wdwsteth.svg` and friends.
|
|
17
13
|
*/
|
|
18
|
-
export declare function
|
|
14
|
+
export declare function getTokenIconUrl(token: TokenIconInput | string | undefined): string;
|
|
@@ -10,9 +10,8 @@ import { RoundedImageProps } from '../rounded-image/rounded-image';
|
|
|
10
10
|
*
|
|
11
11
|
* Props:
|
|
12
12
|
* - `token` — token as it comes from the SDK/backend, or a bare symbol (preferred).
|
|
13
|
-
* The component resolves the
|
|
14
|
-
*
|
|
15
|
-
* - `symbol` — already-resolved source: bare symbol or direct icon URL (legacy).
|
|
13
|
+
* The component resolves the CDN url itself, so callers never pass one.
|
|
14
|
+
* - `symbol` — bare symbol, same thing for call sites that have no token object.
|
|
16
15
|
* - `size` — icon size in pixels (defaults to 48).
|
|
17
16
|
*
|
|
18
17
|
* Note: Fetches icon from Gearbox static CDN based on symbol.
|
|
@@ -24,17 +23,10 @@ import { RoundedImageProps } from '../rounded-image/rounded-image';
|
|
|
24
23
|
* - for address identifiers (use Identicon component).
|
|
25
24
|
* - for custom images or logos (use Image component).
|
|
26
25
|
*/
|
|
27
|
-
type DirectIcon = {
|
|
28
|
-
icon: string;
|
|
29
|
-
};
|
|
30
|
-
export type SymbolOrIcon = string | DirectIcon;
|
|
31
26
|
export interface TokenIconProps extends Omit<RoundedImageProps, "src" | "size"> {
|
|
32
|
-
/**
|
|
33
|
-
* Token (or bare symbol). When set, takes precedence over `symbol` and is
|
|
34
|
-
* resolved via `getTokenIcon` (the GEAR logo override).
|
|
35
|
-
*/
|
|
27
|
+
/** Token (or bare symbol). Takes precedence over `symbol` when both are set. */
|
|
36
28
|
token?: TokenIconInput | string;
|
|
37
|
-
symbol?:
|
|
29
|
+
symbol?: string | undefined;
|
|
38
30
|
size?: number;
|
|
39
31
|
className?: string;
|
|
40
32
|
}
|
|
@@ -9,7 +9,7 @@ declare const tokenSymbolVariants: (props?: ({
|
|
|
9
9
|
export interface TokenSymbolProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "title">, VariantProps<typeof tokenSymbolVariants> {
|
|
10
10
|
/**
|
|
11
11
|
* SDK `Token`, `TokenMetaInfo`, or bare symbol string. Passed straight to
|
|
12
|
-
* `TokenIcon`, which resolves the
|
|
12
|
+
* `TokenIcon`, which resolves the CDN url from the symbol.
|
|
13
13
|
*/
|
|
14
14
|
token?: Token | TokenMetaInfo | string;
|
|
15
15
|
/**
|
|
@@ -2,7 +2,7 @@ import { Address } from 'viem';
|
|
|
2
2
|
/**
|
|
3
3
|
* Token metadata as it arrives from the SDK or backend. Deliberately carries no
|
|
4
4
|
* icon field: icons are a front-end concern resolved from the symbol by
|
|
5
|
-
* `
|
|
5
|
+
* `getTokenIconUrl` inside `TokenIcon`.
|
|
6
6
|
*/
|
|
7
7
|
export type TokenMetaInfo = {
|
|
8
8
|
symbol: string;
|