@gearbox-protocol/ui-kit 4.0.0-next.45 → 4.0.0-next.46

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"});class s{static root="position-assets-root";static row="position-assets-row";static empty="position-assets-empty"}exports.PositionAssetsTest=s;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class s{static root="position-assets-root";static row="position-assets-row";static worth="position-assets-worth";static empty="position-assets-empty"}exports.PositionAssetsTest=s;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),h=require("../stack/stack.cjs");require("../../help-tip/help-tip.cjs");require("react");require("react-intl");require("@gearbox-protocol/sdk/onchain");require("clsx");require("tailwind-merge");require("sonner");const m=require("../../../utils/format.cjs");require("luxon");require("../../../utils/z-index.cjs");require("../../points-icon/points-icon.cjs");const u=require("../values/scalars.cjs");require("../../badge/badge.cjs");require("../../badge/chip.cjs");const p=require("../../short-string/short-string.cjs"),k=require("../../token-symbol/token-symbol.cjs"),g=require("../../typography/typography.cjs"),c=require("./constants.cjs"),_=1,f=20;function q({assets:r,to:o,empty:i,approximate:l,testId:e}){const n=d(r,o),a=o!==void 0;return t.jsx(h.Stack,{gap:"sm",align:"end","data-testid":e??c.PositionAssetsTest.root,children:n.length===0?i!==void 0&&t.jsx(g.Typography,{variant:"caption",color:"secondary",as:"div","data-testid":c.PositionAssetsTest.empty,children:i}):n.map(s=>t.jsxs("span",{className:"flex items-center gap-2","data-testid":c.PositionAssetsTest.row,children:[t.jsx(k.TokenSymbol,{size:20,token:s.token}),t.jsxs("span",{className:"flex items-center",children:[a&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"text-secondary-foreground line-through [&_*]:text-secondary-foreground [&_*]:line-through",children:t.jsx(u.TokenBigint,{data:s.value,token:s.token,showSymbol:!1})}),t.jsx("span",{className:"px-1.5 text-gray-70",children:"→"})]}),l?t.jsx("span",{children:m.APPROXIMATE_SYMBOL}):null,t.jsx(u.TokenBigint,{data:a?s.valueTo:s.value,token:s.token,showSymbol:!1}),t.jsx(p.ShortString,{className:"ml-1",maxLength:f,children:s.token.symbol})]})]},s.token.address))})}function d(r,o){const i=new Map,l=(e,n)=>{const a=e.token.address.toLowerCase(),s=i.get(a);i.set(a,{token:s?.token??e.token,value:n==="from"?e.value:s?.value??0n,valueTo:n==="to"?e.value:s?.valueTo??0n,worth:v(s?.worth,e.valueUsd)})};for(const e of r??[])l(e,"from");for(const e of o??[])l(e,"to");return[...i.values()].filter(e=>e.worth===null||e.worth>=_).sort((e,n)=>(n.worth??0)-(e.worth??0)||e.token.address.localeCompare(n.token.address))}function v(r,o){return r===void 0?o:r===null||o===null?null:Math.max(r,o)}exports.PositionAssetsTest=c.PositionAssetsTest;exports.PositionAssets=q;exports.visibleAssets=d;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),p=require("../stack/stack.cjs"),v=require("../values/no-value.cjs");require("react");require("@gearbox-protocol/sdk/onchain");require("clsx");require("tailwind-merge");require("sonner");const f=require("../../../utils/format.cjs"),_=require("../../../utils/format-money.cjs");require("luxon");require("../../../utils/z-index.cjs");require("../../points-icon/points-icon.cjs");const d=require("../values/scalars.cjs");require("../../badge/badge.cjs");require("../../badge/chip.cjs");require("react-intl");const x=require("../../short-string/short-string.cjs"),y=require("../../token-symbol/token-symbol.cjs"),h=require("../../typography/typography.cjs"),l=require("./constants.cjs"),g=1,k=20;function q({assets:r,to:n,empty:a,approximate:c,testId:e}){const o=m(r,n),i=n!==void 0;return t.jsx(p.Stack,{gap:"sm",align:"end","data-testid":e??l.PositionAssetsTest.root,children:o.length===0?a!==void 0&&t.jsx(h.Typography,{variant:"caption",color:"secondary",as:"div","data-testid":l.PositionAssetsTest.empty,children:a}):o.map(s=>{const u=i?s.valueToUsd:s.valueUsd;return t.jsxs("span",{className:"flex flex-col items-end","data-testid":l.PositionAssetsTest.row,children:[t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(y.TokenSymbol,{size:20,token:s.token}),t.jsxs("span",{className:"flex items-center",children:[i&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"text-secondary-foreground line-through [&_*]:text-secondary-foreground [&_*]:line-through",children:t.jsx(d.TokenBigint,{data:s.value,token:s.token,showSymbol:!1})}),t.jsx("span",{className:"px-1.5 text-gray-70",children:"→"})]}),c?t.jsx("span",{children:f.APPROXIMATE_SYMBOL}):null,t.jsx(d.TokenBigint,{data:i?s.valueTo:s.value,token:s.token,showSymbol:!1}),t.jsx(x.ShortString,{className:"ml-1",maxLength:k,children:s.token.symbol})]})]}),t.jsx(h.Typography,{as:"span",variant:"caption",color:"secondary","data-testid":l.PositionAssetsTest.worth,children:u===null?t.jsx(v.NoValue,{}):_.formatMoney(u)})]},s.token.address)})})}function m(r,n){const a=new Map,c=(e,o)=>{const i=e.token.address.toLowerCase(),s=a.get(i);a.set(i,{token:s?.token??e.token,value:o==="from"?e.value:s?.value??0n,valueTo:o==="to"?e.value:s?.valueTo??0n,valueUsd:o==="from"?e.valueUsd:s?.valueUsd??null,valueToUsd:o==="to"?e.valueUsd:s?.valueToUsd??null,worth:T(s?.worth,e.valueUsd)})};for(const e of r??[])c(e,"from");for(const e of n??[])c(e,"to");return[...a.values()].filter(e=>e.worth===null||e.worth>=g).sort((e,o)=>(o.worth??0)-(e.worth??0)||e.token.address.localeCompare(o.token.address))}function T(r,n){return r===void 0?n:r===null||n===null?null:Math.max(r,n)}exports.PositionAssetsTest=l.PositionAssetsTest;exports.PositionAssets=q;exports.visibleAssets=m;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),u=require("../stack/stack.cjs"),i=require("../values/no-value.cjs");require("react");require("@gearbox-protocol/sdk/onchain");require("clsx");require("tailwind-merge");require("sonner");const a=require("../../../utils/format-money.cjs");require("luxon");require("../../../utils/z-index.cjs");require("../../points-icon/points-icon.cjs");require("viem");require("../../token-icon/token-icon.cjs");require("react-intl");require("../../tooltip/simple-tooltip.cjs");require("../../tooltip/tooltip.cjs");require("../../badge/badge.cjs");require("../../badge/chip.cjs");const c=require("../../token-template/token-template.cjs"),l=require("../../typography/typography.cjs"),n=require("./constants.cjs");function q({data:e,token:o,align:t="end"}){if(e===null)return r.jsx("span",{className:"text-secondary-foreground","data-testid":n.TokenAmountTest.root,children:"—"});const s=o??e.token;return r.jsxs(u.Stack,{gap:"xs",align:t,"data-testid":n.TokenAmountTest.root,children:[r.jsx(c.TokenTemplate,{value:e.value,token:s}),r.jsx(l.Typography,{as:"span",variant:"caption",color:"secondary",children:e.valueUsd===null?r.jsx(i.NoValue,{}):a.formatMoney(e.valueUsd)})]})}exports.TokenAmountTest=n.TokenAmountTest;exports.TokenAmount=q;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),i=require("../stack/stack.cjs"),a=require("../values/no-value.cjs");require("react");require("@gearbox-protocol/sdk/onchain");require("clsx");require("tailwind-merge");require("sonner");const c=require("../../../utils/format.cjs"),l=require("../../../utils/format-money.cjs");require("luxon");require("../../../utils/z-index.cjs");require("../../points-icon/points-icon.cjs");require("viem");require("../../token-icon/token-icon.cjs");require("react-intl");require("../../tooltip/simple-tooltip.cjs");require("../../tooltip/tooltip.cjs");require("../../badge/badge.cjs");require("../../badge/chip.cjs");const m=require("../../token-template/token-template.cjs"),q=require("../../typography/typography.cjs"),n=require("./constants.cjs");function p({data:r,token:o,align:t="end",approximate:s}){if(r===null)return e.jsx("span",{className:"text-secondary-foreground","data-testid":n.TokenAmountTest.root,children:"—"});const u=o??r.token;return e.jsxs(i.Stack,{gap:"xs",align:t,"data-testid":n.TokenAmountTest.root,children:[e.jsxs("span",{className:"flex items-center",children:[s?e.jsx("span",{className:"mr-0.5",children:c.APPROXIMATE_SYMBOL}):null,e.jsx(m.TokenTemplate,{value:r.value,token:u})]}),e.jsx(q.Typography,{as:"span",variant:"caption",color:"secondary",children:r.valueUsd===null?e.jsx(a.NoValue,{}):l.formatMoney(r.valueUsd)})]})}exports.TokenAmountTest=n.TokenAmountTest;exports.TokenAmount=p;
@@ -1,6 +1,7 @@
1
1
  class t {
2
2
  static root = "position-assets-root";
3
3
  static row = "position-assets-row";
4
+ static worth = "position-assets-worth";
4
5
  static empty = "position-assets-empty";
5
6
  }
6
7
  export {
@@ -1,99 +1,117 @@
1
- import { jsx as e, jsxs as m, Fragment as p } from "react/jsx-runtime";
1
+ import { jsx as e, jsxs as m, Fragment as f } from "react/jsx-runtime";
2
2
  import { Stack as h } from "../stack/stack.js";
3
- import "../../help-tip/help-tip.js";
3
+ import { NoValue as v } from "../values/no-value.js";
4
4
  import "react";
5
- import "react-intl";
6
5
  import "@gearbox-protocol/sdk/onchain";
7
6
  import "clsx";
8
7
  import "tailwind-merge";
9
8
  import "sonner";
10
- import { APPROXIMATE_SYMBOL as f } from "../../../utils/format.js";
9
+ import { APPROXIMATE_SYMBOL as k } from "../../../utils/format.js";
10
+ import { formatMoney as g } from "../../../utils/format-money.js";
11
11
  import "luxon";
12
12
  import "../../../utils/z-index.js";
13
13
  import "../../points-icon/points-icon.js";
14
- import { TokenBigint as d } from "../values/scalars.js";
14
+ import { TokenBigint as p } from "../values/scalars.js";
15
15
  import "../../badge/badge.js";
16
16
  import "../../badge/chip.js";
17
- import { ShortString as u } from "../../short-string/short-string.js";
18
- import { TokenSymbol as k } from "../../token-symbol/token-symbol.js";
19
- import { Typography as v } from "../../typography/typography.js";
20
- import { PositionAssetsTest as c } from "./constants.js";
21
- const g = 1, y = 20;
22
- function I({
17
+ import "react-intl";
18
+ import { ShortString as y } from "../../short-string/short-string.js";
19
+ import { TokenSymbol as T } from "../../token-symbol/token-symbol.js";
20
+ import { Typography as u } from "../../typography/typography.js";
21
+ import { PositionAssetsTest as d } from "./constants.js";
22
+ const x = 1, U = 20;
23
+ function G({
23
24
  assets: s,
24
- to: r,
25
+ to: n,
25
26
  empty: a,
26
- approximate: l,
27
+ approximate: i,
27
28
  testId: o
28
29
  }) {
29
- const n = S(s, r), i = r !== void 0;
30
- return /* @__PURE__ */ e(h, { gap: "sm", align: "end", "data-testid": o ?? c.root, children: n.length === 0 ? a !== void 0 && /* @__PURE__ */ e(
31
- v,
30
+ const r = S(s, n), l = n !== void 0;
31
+ return /* @__PURE__ */ e(h, { gap: "sm", align: "end", "data-testid": o ?? d.root, children: r.length === 0 ? a !== void 0 && /* @__PURE__ */ e(
32
+ u,
32
33
  {
33
34
  variant: "caption",
34
35
  color: "secondary",
35
36
  as: "div",
36
- "data-testid": c.empty,
37
+ "data-testid": d.empty,
37
38
  children: a
38
39
  }
39
- ) : n.map((t) => /* @__PURE__ */ m(
40
- "span",
41
- {
42
- className: "flex items-center gap-2",
43
- "data-testid": c.row,
44
- children: [
45
- /* @__PURE__ */ e(k, { size: 20, token: t.token }),
46
- /* @__PURE__ */ m("span", { className: "flex items-center", children: [
47
- i && /* @__PURE__ */ m(p, { children: [
48
- /* @__PURE__ */ e("span", { className: "text-secondary-foreground line-through [&_*]:text-secondary-foreground [&_*]:line-through", children: /* @__PURE__ */ e(
49
- d,
50
- {
51
- data: t.value,
52
- token: t.token,
53
- showSymbol: !1
54
- }
55
- ) }),
56
- /* @__PURE__ */ e("span", { className: "px-1.5 text-gray-70", children: "→" })
40
+ ) : r.map((t) => {
41
+ const c = l ? t.valueToUsd : t.valueUsd;
42
+ return /* @__PURE__ */ m(
43
+ "span",
44
+ {
45
+ className: "flex flex-col items-end",
46
+ "data-testid": d.row,
47
+ children: [
48
+ /* @__PURE__ */ m("span", { className: "flex items-center gap-2", children: [
49
+ /* @__PURE__ */ e(T, { size: 20, token: t.token }),
50
+ /* @__PURE__ */ m("span", { className: "flex items-center", children: [
51
+ l && /* @__PURE__ */ m(f, { children: [
52
+ /* @__PURE__ */ e("span", { className: "text-secondary-foreground line-through [&_*]:text-secondary-foreground [&_*]:line-through", children: /* @__PURE__ */ e(
53
+ p,
54
+ {
55
+ data: t.value,
56
+ token: t.token,
57
+ showSymbol: !1
58
+ }
59
+ ) }),
60
+ /* @__PURE__ */ e("span", { className: "px-1.5 text-gray-70", children: "→" })
61
+ ] }),
62
+ i ? /* @__PURE__ */ e("span", { children: k }) : null,
63
+ /* @__PURE__ */ e(
64
+ p,
65
+ {
66
+ data: l ? t.valueTo : t.value,
67
+ token: t.token,
68
+ showSymbol: !1
69
+ }
70
+ ),
71
+ /* @__PURE__ */ e(y, { className: "ml-1", maxLength: U, children: t.token.symbol })
72
+ ] })
57
73
  ] }),
58
- l ? /* @__PURE__ */ e("span", { children: f }) : null,
59
74
  /* @__PURE__ */ e(
60
- d,
75
+ u,
61
76
  {
62
- data: i ? t.valueTo : t.value,
63
- token: t.token,
64
- showSymbol: !1
77
+ as: "span",
78
+ variant: "caption",
79
+ color: "secondary",
80
+ "data-testid": d.worth,
81
+ children: c === null ? /* @__PURE__ */ e(v, {}) : g(c)
65
82
  }
66
- ),
67
- /* @__PURE__ */ e(u, { className: "ml-1", maxLength: y, children: t.token.symbol })
68
- ] })
69
- ]
70
- },
71
- t.token.address
72
- )) });
83
+ )
84
+ ]
85
+ },
86
+ t.token.address
87
+ );
88
+ }) });
73
89
  }
74
- function S(s, r) {
75
- const a = /* @__PURE__ */ new Map(), l = (o, n) => {
76
- const i = o.token.address.toLowerCase(), t = a.get(i);
77
- a.set(i, {
90
+ function S(s, n) {
91
+ const a = /* @__PURE__ */ new Map(), i = (o, r) => {
92
+ const l = o.token.address.toLowerCase(), t = a.get(l);
93
+ a.set(l, {
78
94
  token: t?.token ?? o.token,
79
95
  // a token only the other side holds is a zero here, not a gap
80
- value: n === "from" ? o.value : t?.value ?? 0n,
81
- valueTo: n === "to" ? o.value : t?.valueTo ?? 0n,
82
- worth: x(t?.worth, o.valueUsd)
96
+ value: r === "from" ? o.value : t?.value ?? 0n,
97
+ valueTo: r === "to" ? o.value : t?.valueTo ?? 0n,
98
+ valueUsd: r === "from" ? o.valueUsd : t?.valueUsd ?? null,
99
+ valueToUsd: r === "to" ? o.valueUsd : t?.valueToUsd ?? null,
100
+ worth: M(t?.worth, o.valueUsd)
83
101
  });
84
102
  };
85
- for (const o of s ?? []) l(o, "from");
86
- for (const o of r ?? []) l(o, "to");
87
- return [...a.values()].filter((o) => o.worth === null || o.worth >= g).sort(
88
- (o, n) => (n.worth ?? 0) - (o.worth ?? 0) || // a tie has to break the same way every render, or the rows drift
89
- o.token.address.localeCompare(n.token.address)
103
+ for (const o of s ?? []) i(o, "from");
104
+ for (const o of n ?? []) i(o, "to");
105
+ return [...a.values()].filter((o) => o.worth === null || o.worth >= x).sort(
106
+ (o, r) => (r.worth ?? 0) - (o.worth ?? 0) || // a tie has to break the same way every render, or the rows drift
107
+ o.token.address.localeCompare(r.token.address)
90
108
  );
91
109
  }
92
- function x(s, r) {
93
- return s === void 0 ? r : s === null || r === null ? null : Math.max(s, r);
110
+ function M(s, n) {
111
+ return s === void 0 ? n : s === null || n === null ? null : Math.max(s, n);
94
112
  }
95
113
  export {
96
- I as PositionAssets,
97
- c as PositionAssetsTest,
114
+ G as PositionAssets,
115
+ d as PositionAssetsTest,
98
116
  S as visibleAssets
99
117
  };
@@ -1,12 +1,13 @@
1
- import { jsx as r, jsxs as e } from "react/jsx-runtime";
2
- import { Stack as n } from "../stack/stack.js";
1
+ import { jsx as r, jsxs as t } from "react/jsx-runtime";
2
+ import { Stack as s } from "../stack/stack.js";
3
3
  import { NoValue as a } from "../values/no-value.js";
4
4
  import "react";
5
5
  import "@gearbox-protocol/sdk/onchain";
6
6
  import "clsx";
7
7
  import "tailwind-merge";
8
8
  import "sonner";
9
- import { formatMoney as s } from "../../../utils/format-money.js";
9
+ import { APPROXIMATE_SYMBOL as l } from "../../../utils/format.js";
10
+ import { formatMoney as c } from "../../../utils/format-money.js";
10
11
  import "luxon";
11
12
  import "../../../utils/z-index.js";
12
13
  import "../../points-icon/points-icon.js";
@@ -17,30 +18,34 @@ import "../../tooltip/simple-tooltip.js";
17
18
  import "../../tooltip/tooltip.js";
18
19
  import "../../badge/badge.js";
19
20
  import "../../badge/chip.js";
20
- import { TokenTemplate as l } from "../../token-template/token-template.js";
21
- import { Typography as u } from "../../typography/typography.js";
22
- import { TokenAmountTest as t } from "./constants.js";
23
- function C({
21
+ import { TokenTemplate as u } from "../../token-template/token-template.js";
22
+ import { Typography as f } from "../../typography/typography.js";
23
+ import { TokenAmountTest as m } from "./constants.js";
24
+ function Y({
24
25
  data: o,
25
- token: m,
26
- align: i = "end"
26
+ token: e,
27
+ align: i = "end",
28
+ approximate: n
27
29
  }) {
28
30
  if (o === null)
29
31
  return /* @__PURE__ */ r(
30
32
  "span",
31
33
  {
32
34
  className: "text-secondary-foreground",
33
- "data-testid": t.root,
35
+ "data-testid": m.root,
34
36
  children: "—"
35
37
  }
36
38
  );
37
- const p = m ?? o.token;
38
- return /* @__PURE__ */ e(n, { gap: "xs", align: i, "data-testid": t.root, children: [
39
- /* @__PURE__ */ r(l, { value: o.value, token: p }),
40
- /* @__PURE__ */ r(u, { as: "span", variant: "caption", color: "secondary", children: o.valueUsd === null ? /* @__PURE__ */ r(a, {}) : s(o.valueUsd) })
39
+ const p = e ?? o.token;
40
+ return /* @__PURE__ */ t(s, { gap: "xs", align: i, "data-testid": m.root, children: [
41
+ /* @__PURE__ */ t("span", { className: "flex items-center", children: [
42
+ n ? /* @__PURE__ */ r("span", { className: "mr-0.5", children: l }) : null,
43
+ /* @__PURE__ */ r(u, { value: o.value, token: p })
44
+ ] }),
45
+ /* @__PURE__ */ r(f, { as: "span", variant: "caption", color: "secondary", children: o.valueUsd === null ? /* @__PURE__ */ r(a, {}) : c(o.valueUsd) })
41
46
  ] });
42
47
  }
43
48
  export {
44
- C as TokenAmount,
45
- t as TokenAmountTest
49
+ Y as TokenAmount,
50
+ m as TokenAmountTest
46
51
  };
@@ -1,5 +1,6 @@
1
1
  export declare class PositionAssetsTest {
2
2
  static root: string;
3
3
  static row: string;
4
+ static worth: string;
4
5
  static empty: string;
5
6
  }
@@ -53,6 +53,10 @@ export interface AssetRow {
53
53
  * dust and order. `null` when a side the oracle cannot price is involved.
54
54
  */
55
55
  readonly worth: number | null;
56
+ /** USD of the "now" side; `null` where the oracle could not price it. */
57
+ readonly valueUsd: number | null;
58
+ /** USD of the "after" side, for the caption a paired row shows. */
59
+ readonly valueToUsd: number | null;
56
60
  }
57
61
  /**
58
62
  * What earns a row, most valuable first — decided across both sides, so a
@@ -28,5 +28,12 @@ export type TokenAmountProps = TokenAmountDataProps & {
28
28
  * wrapper sets. Pass `start` inside a card, where the left edge is right.
29
29
  */
30
30
  readonly align?: TokenAmountAlign;
31
+ /**
32
+ * Prefixes the token line with {@link APPROXIMATE_SYMBOL}, for a figure the
33
+ * operation projects rather than promises. The USD caption underneath is not
34
+ * marked: the mark belongs beside the amount it hedges, and repeating it on
35
+ * the second line only reads as a second claim.
36
+ */
37
+ readonly approximate?: boolean;
31
38
  };
32
- export declare function TokenAmount({ data, token, align, }: TokenAmountProps): React.ReactElement;
39
+ export declare function TokenAmount({ data, token, align, approximate, }: TokenAmountProps): React.ReactElement;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/ui-kit",
3
- "version": "4.0.0-next.45",
3
+ "version": "4.0.0-next.46",
4
4
  "description": "Internal UI components",
5
5
  "repository": {
6
6
  "type": "git",