@gearbox-protocol/ui-kit 4.0.0-next.83 → 4.0.0-next.84

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 o=require("../../utils/internal/static.cjs"),c=o.getStatic("/tokens/templates/diesel.svg"),u=o.getStatic("/logo/logo_symbol.png"),n=/V\d+$/,s="_OLD",f=[{prefix:"farmd",requiresVersion:!1},{prefix:"wd",requiresVersion:!1},{prefix:"sd",requiresVersion:!0},{prefix:"d",requiresVersion:!0}];function l(e){for(const{prefix:t,requiresVersion:i}of f){if(!e.startsWith(t))continue;let r=e.slice(t.length);if(r.endsWith(s)&&(r=r.slice(0,-s.length)),n.test(r))r=r.replace(n,"");else if(i)continue;if(r)return r}}function d(e){return{kind:"composite",preset:"centered_foreground",scaleFactor:.74,layers:[{type:"url",url:c},{type:"symbol",symbol:e}]}}function a(e){if(e===void 0)return;const t=typeof e=="string"?e:e.symbol;if(!t)return;if(t==="GEAR")return{icon:u};const i=l(t);return i?d(i):t}exports.getTokenIcon=a;exports.parseShareTokenUnderlying=l;
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 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),j=require("react"),h=require("./token-icon-source.cjs"),y=require("../../utils/cn.cjs");require("@gearbox-protocol/sdk/onchain");require("../../utils/z-index.cjs");const p=require("../../utils/internal/static.cjs"),d=require("../rounded-image/rounded-image.cjs"),f=p.getStatic("/tokens/default.svg");function x(e){return e.replace("/","").replace(" ","").replace("-f","").replace("-","_").toLowerCase()}function w(e){return typeof e=="object"&&e!==null&&"icon"in e&&!("kind"in e)}function S(e){return typeof e=="object"&&e!==null&&"kind"in e&&e.kind==="composite"}function T(e){if(e.type==="url")return e.url;const n=x(e.symbol);return n?p.getStatic(`/tokens/${n}.svg`):f}function N(e){if(!e||S(e))return f;if(w(e))return e.icon;const n=x(e);return n?p.getStatic(`/tokens/${n}.svg`):f}const C=.65;function U(e,n){return e!==void 0?h.getTokenIcon(e):typeof n=="string"?h.getTokenIcon(n):n}const _=j.forwardRef(function({token:n,symbol:r,size:o=48,fit:c="contain",rounded:i=!1,className:a,...u},l){const s=U(n,r);if(S(s))return t.jsx(b,{ref:l,composite:s,size:o,fit:c,rounded:i,className:a});const m=N(s);return t.jsx(d.RoundedImage,{ref:l,className:a,src:m,alt:"",rounded:i,fit:c,width:o,height:o,size:o,...u})}),b=j.forwardRef(function({composite:n,size:r,fit:o,rounded:c,className:i},a){const{preset:u,layers:l,scaleFactor:s=C}=n,[m,R]=l,k=T(m),q=T(R),g=Math.round(r*s);let I;switch(u){case"centered_foreground":I=t.jsxs(t.Fragment,{children:[t.jsx(d.RoundedImage,{className:"absolute inset-0",style:{zIndex:0},src:k,alt:"background",rounded:c,fit:o,size:r}),t.jsx("div",{className:y.cn("absolute left-1/2 top-1/2 z-[1] -translate-x-1/2 -translate-y-1/2","flex items-center justify-center"),style:{width:g,height:g},children:t.jsx(d.RoundedImage,{src:q,alt:"foreground",rounded:c,fit:o,size:g})})]});break;default:return console.error("Unknown TokenIcon composite preset",u),t.jsx(d.RoundedImage,{src:k,alt:"error",rounded:c,fit:o,size:r})}return t.jsx("div",{ref:a,className:y.cn("relative inline-block shrink-0",i),style:{width:r,height:r},children:I})});b.displayName="TokenIconComposite";_.displayName="TokenIcon";exports.TokenIcon=_;
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,48 +1,11 @@
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
- }
18
- }
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;
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;
44
8
  }
45
9
  export {
46
- g as getTokenIcon,
47
- c as parseShareTokenUnderlying
10
+ c as getTokenIcon
48
11
  };
@@ -1,143 +1,54 @@
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();
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();
12
9
  }
13
- function _(t) {
14
- return typeof t == "object" && t !== null && "icon" in t && !("kind" in t);
10
+ function k(n) {
11
+ return typeof n == "object" && n !== null && "icon" in n;
15
12
  }
16
- function N(t) {
17
- return typeof t == "object" && t !== null && "kind" in t && t.kind === "composite";
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;
18
19
  }
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;
20
+ function _(n, e) {
21
+ return n !== void 0 ? t(n) : typeof e == "string" ? t(e) : e;
23
22
  }
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,
23
+ const h = I.forwardRef(
24
+ 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,
49
36
  {
50
- ref: f,
51
- composite: i,
52
- size: o,
53
- fit: c,
54
- rounded: s,
55
- className: a
37
+ ref: m,
38
+ className: a,
39
+ src: s,
40
+ alt: "",
41
+ rounded: u,
42
+ fit: f,
43
+ width: r,
44
+ height: r,
45
+ size: r,
46
+ ...p
56
47
  }
57
48
  );
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
49
  }
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";
50
+ );
51
+ h.displayName = "TokenIcon";
141
52
  export {
142
- v as TokenIcon
53
+ h as TokenIcon
143
54
  };
@@ -1,32 +1,7 @@
1
- /** One layer of a composite icon: a token symbol to resolve, or a ready URL. */
2
- export type TokenIconLayerSource = {
3
- type: "symbol";
4
- symbol: string;
5
- } | {
6
- type: "url";
7
- url: string;
8
- };
9
- /**
10
- * Named layout preset for a composite icon. The pixel layout is `TokenIcon`'s,
11
- * never an API payload's — which is why these types live here and not in the
12
- * SDK read model.
13
- *
14
- * `centered_foreground`: background full size, foreground centered at ~65%
15
- * (a token on a plate).
16
- */
17
- export type TokenIconCompositePreset = "centered_foreground";
18
- /** Client-composed token icon: layers stacked by preset. */
19
- export type IconComposite = {
20
- kind: "composite";
21
- preset: TokenIconCompositePreset;
22
- scaleFactor?: number;
23
- /** Exactly two layers (bottom then top). */
24
- layers: readonly [TokenIconLayerSource, TokenIconLayerSource];
25
- };
26
1
  /** Same shape as `TokenIcon`'s `symbol` prop — kept here to avoid a cycle. */
27
2
  export type TokenIconSource = string | {
28
3
  icon: string;
29
- } | IconComposite;
4
+ };
30
5
  /**
31
6
  * Everything the resolver needs from a token. Structural on purpose so the SDK
32
7
  * read-model `Token`, the `TokenData` class, and bare metadata all fit without
@@ -36,17 +11,8 @@ export interface TokenIconInput {
36
11
  symbol: string;
37
12
  }
38
13
  /**
39
- * Underlying symbol of a pool share token, or `undefined` when the symbol is
40
- * an ordinary token. Falling through is safe: the caller then uses the token's
41
- * own CDN asset.
42
- */
43
- export declare function parseShareTokenUnderlying(symbol: string): string | undefined;
44
- /**
45
- * Resolve a token (or bare symbol) into the value `TokenIcon` renders.
46
- *
47
- * Pure front-end concern: share token composites and the GEAR logo special
48
- * case are derived from the symbol alone — callers must not pre-bake `icon` /
49
- * `iconUrl`, and should hand the token to `TokenIcon` rather than calling this
50
- * directly.
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.
51
17
  */
52
18
  export declare function getTokenIcon(token: TokenIconInput | string | undefined): TokenIconSource | undefined;
@@ -1,5 +1,5 @@
1
1
  import { default as React } from 'react';
2
- import { IconComposite, TokenIconInput } from './token-icon-source';
2
+ import { TokenIconInput } from './token-icon-source';
3
3
  import { RoundedImageProps } from '../rounded-image/rounded-image';
4
4
  /**
5
5
  * TokenIcon — component for displaying token/asset icons.
@@ -12,7 +12,7 @@ import { RoundedImageProps } from '../rounded-image/rounded-image';
12
12
  * - `token` — token as it comes from the SDK/backend, or a bare symbol (preferred).
13
13
  * The component resolves the icon itself via `getTokenIcon`, so callers never
14
14
  * pass a pre-baked URL.
15
- * - `symbol` — already-resolved source: direct icon URL or `IconComposite` (legacy).
15
+ * - `symbol` — already-resolved source: bare symbol or direct icon URL (legacy).
16
16
  * - `size` — icon size in pixels (defaults to 48).
17
17
  *
18
18
  * Note: Fetches icon from Gearbox static CDN based on symbol.
@@ -20,9 +20,6 @@ import { RoundedImageProps } from '../rounded-image/rounded-image';
20
20
  * Symbol is normalized (removes "/", spaces, "-f", converts "-" to "_", lowercased).
21
21
  * Icon displays in its original shape (not clipped).
22
22
  *
23
- * **Ref behavior:** In the default single-image mode, `ref` is attached to the underlying `<img>`.
24
- * In composite mode, `ref` is attached to the outer wrapper `div` (see `TokenIconProps` / `forwardRef` generic).
25
- *
26
23
  * Do NOT use TokenIcon:
27
24
  * - for address identifiers (use Identicon component).
28
25
  * - for custom images or logos (use Image component).
@@ -30,16 +27,16 @@ import { RoundedImageProps } from '../rounded-image/rounded-image';
30
27
  type DirectIcon = {
31
28
  icon: string;
32
29
  };
33
- export type SymbolOrIcon = string | DirectIcon | IconComposite;
30
+ export type SymbolOrIcon = string | DirectIcon;
34
31
  export interface TokenIconProps extends Omit<RoundedImageProps, "src" | "size"> {
35
32
  /**
36
33
  * Token (or bare symbol). When set, takes precedence over `symbol` and is
37
- * resolved via `getTokenIcon` (diesel composites, GEAR logo, etc.).
34
+ * resolved via `getTokenIcon` (the GEAR logo override).
38
35
  */
39
36
  token?: TokenIconInput | string;
40
37
  symbol?: SymbolOrIcon | undefined;
41
38
  size?: number;
42
39
  className?: string;
43
40
  }
44
- declare const TokenIcon: React.ForwardRefExoticComponent<TokenIconProps & React.RefAttributes<HTMLDivElement | HTMLImageElement>>;
41
+ declare const TokenIcon: React.ForwardRefExoticComponent<TokenIconProps & React.RefAttributes<HTMLImageElement>>;
45
42
  export { TokenIcon };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/ui-kit",
3
- "version": "4.0.0-next.83",
3
+ "version": "4.0.0-next.84",
4
4
  "description": "Internal UI components",
5
5
  "repository": {
6
6
  "type": "git",