@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.
@@ -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 o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(r,n,o.get?o:{enumerable:!0,get:()=>e[n]})}}return r.default=e,Object.freeze(r)}const T=S(c),g=L.getStatic("/tokens/default.svg"),m=new Map;function f(e){return m.get(e)?g:e}const b=T.forwardRef(({className:e,size:r,rounded:n=!0,style:o,src:s,defaultIcon:p=g,fit:y="cover",...R},a)=>{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 a=="function"?a(t):a&&(a.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,...o},loading:"lazy",decoding:"async",onError:O,onLoad:_,...R})});b.displayName="RoundedImage";exports.RoundedImage=b;
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 e=require("../../utils/internal/static.cjs"),i=e.getStatic("/logo/logo_symbol.png");function n(t){if(t===void 0)return;const o=typeof t=="string"?t:t.symbol;if(o)return o==="GEAR"?{icon:i}:o}exports.getTokenIcon=n;
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 l=require("react/jsx-runtime"),k=require("react"),o=require("./token-icon-source.cjs"),c=require("../../utils/internal/static.cjs"),p=require("../rounded-image/rounded-image.cjs"),r=c.getStatic("/tokens/default.svg");function T(e){return e.replace("/","").replace(" ","").replace("-f","").replace("-","_").toLowerCase()}function m(e){return typeof e=="object"&&e!==null&&"icon"in e}function _(e){if(!e)return r;if(m(e))return e.icon;const n=T(e);return n?c.getStatic(`/tokens/${n}.svg`):r}function S(e,n){return e!==void 0?o.getTokenIcon(e):typeof n=="string"?o.getTokenIcon(n):n}const i=k.forwardRef(function({token:n,symbol:u,size:t=48,fit:a="contain",rounded:s=!1,className:f,...g},I){const d=_(S(n,u));return l.jsx(p.RoundedImage,{ref:I,className:f,src:d,alt:"",rounded:s,fit:a,width:t,height:t,size:t,...g})});i.displayName="TokenIcon";exports.TokenIcon=i;
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 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,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, 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 /* @__PURE__ */ E(
36
+ return /* @__PURE__ */ I(
37
37
  "img",
38
38
  {
39
- ref: I,
40
- src: v || f(o),
39
+ ref: L,
40
+ src: v || l(o),
41
41
  alt: "",
42
- className: N(
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: L,
56
- onLoad: j,
55
+ onError: j,
56
+ onLoad: E,
57
57
  ...y
58
58
  }
59
59
  );
60
60
  }
61
61
  );
62
- U.displayName = "RoundedImage";
62
+ C.displayName = "RoundedImage";
63
63
  export {
64
- U as RoundedImage
64
+ C as RoundedImage
65
65
  };
@@ -1,11 +1,26 @@
1
- import { getStatic as t } from "../../utils/internal/static.js";
2
- const i = t("/logo/logo_symbol.png");
3
- function c(o) {
4
- if (o === void 0) return;
5
- const r = typeof o == "string" ? o : o.symbol;
6
- if (r)
7
- return r === "GEAR" ? { icon: i } : r;
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
- c as getTokenIcon
25
+ e as getTokenIconUrl
11
26
  };
@@ -1,54 +1,35 @@
1
- import { jsx as g } from "react/jsx-runtime";
2
- import I from "react";
3
- import { getTokenIcon as t } from "./token-icon-source.js";
4
- import { getStatic as c } from "../../utils/internal/static.js";
5
- import { RoundedImage as d } from "../rounded-image/rounded-image.js";
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: e,
26
- symbol: i,
27
- size: r = 48,
28
- fit: f = "contain",
29
- rounded: u = !1,
30
- className: a,
31
- ...p
32
- }, m) {
33
- const s = T(_(e, i));
34
- return /* @__PURE__ */ g(
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: m,
38
- className: a,
39
- src: s,
18
+ ref: c,
19
+ className: m,
20
+ src: d(n ?? r),
40
21
  alt: "",
41
- rounded: u,
42
- fit: f,
43
- width: r,
44
- height: r,
45
- size: r,
46
- ...p
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
- h.displayName = "TokenIcon";
32
+ l.displayName = "TokenIcon";
52
33
  export {
53
- h as TokenIcon
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
- * Resolve a token (or bare symbol) into the value `TokenIcon` renders. Every
15
- * symbol maps to its own CDN asset — share tokens included, the CDN ships
16
- * `dusdcv3.svg`, `sdwethv3.svg`, `wdwsteth.svg` and friends.
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 getTokenIcon(token: TokenIconInput | string | undefined): TokenIconSource | undefined;
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 icon itself via `getTokenIcon`, so callers never
14
- * pass a pre-baked URL.
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?: SymbolOrIcon | undefined;
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 icon via `getTokenIcon`.
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
- * `getTokenIcon` inside `TokenIcon`.
5
+ * `getTokenIconUrl` inside `TokenIcon`.
6
6
  */
7
7
  export type TokenMetaInfo = {
8
8
  symbol: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/ui-kit",
3
- "version": "4.0.0-next.84",
3
+ "version": "4.0.0-next.85",
4
4
  "description": "Internal UI components",
5
5
  "repository": {
6
6
  "type": "git",