@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.
- package/dist/cjs/components/base/position-assets/constants.cjs +1 -1
- package/dist/cjs/components/base/position-assets/position-assets.cjs +1 -1
- package/dist/cjs/components/base/token-amount/token-amount.cjs +1 -1
- package/dist/esm/components/base/position-assets/constants.js +1 -0
- package/dist/esm/components/base/position-assets/position-assets.js +81 -63
- package/dist/esm/components/base/token-amount/token-amount.js +21 -16
- package/dist/types/components/base/position-assets/constants.d.ts +1 -0
- package/dist/types/components/base/position-assets/position-assets.d.ts +4 -0
- package/dist/types/components/base/token-amount/token-amount.d.ts +8 -1
- package/package.json +1 -1
|
@@ -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"),
|
|
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
|
|
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,99 +1,117 @@
|
|
|
1
|
-
import { jsx as e, jsxs as m, Fragment as
|
|
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 "
|
|
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
|
|
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
|
|
14
|
+
import { TokenBigint as p } from "../values/scalars.js";
|
|
15
15
|
import "../../badge/badge.js";
|
|
16
16
|
import "../../badge/chip.js";
|
|
17
|
-
import
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
|
|
22
|
-
|
|
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:
|
|
25
|
+
to: n,
|
|
25
26
|
empty: a,
|
|
26
|
-
approximate:
|
|
27
|
+
approximate: i,
|
|
27
28
|
testId: o
|
|
28
29
|
}) {
|
|
29
|
-
const
|
|
30
|
-
return /* @__PURE__ */ e(h, { gap: "sm", align: "end", "data-testid": o ??
|
|
31
|
-
|
|
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":
|
|
37
|
+
"data-testid": d.empty,
|
|
37
38
|
children: a
|
|
38
39
|
}
|
|
39
|
-
) :
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
/* @__PURE__ */ e(
|
|
49
|
-
|
|
50
|
-
{
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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
|
-
|
|
75
|
+
u,
|
|
61
76
|
{
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
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
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
)) });
|
|
83
|
+
)
|
|
84
|
+
]
|
|
85
|
+
},
|
|
86
|
+
t.token.address
|
|
87
|
+
);
|
|
88
|
+
}) });
|
|
73
89
|
}
|
|
74
|
-
function S(s,
|
|
75
|
-
const a = /* @__PURE__ */ new Map(),
|
|
76
|
-
const
|
|
77
|
-
a.set(
|
|
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:
|
|
81
|
-
valueTo:
|
|
82
|
-
|
|
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 ?? [])
|
|
86
|
-
for (const o of
|
|
87
|
-
return [...a.values()].filter((o) => o.worth === null || o.worth >=
|
|
88
|
-
(o,
|
|
89
|
-
o.token.address.localeCompare(
|
|
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
|
|
93
|
-
return s === void 0 ?
|
|
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
|
-
|
|
97
|
-
|
|
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
|
|
2
|
-
import { Stack as
|
|
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 {
|
|
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
|
|
21
|
-
import { Typography as
|
|
22
|
-
import { TokenAmountTest as
|
|
23
|
-
function
|
|
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:
|
|
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":
|
|
35
|
+
"data-testid": m.root,
|
|
34
36
|
children: "—"
|
|
35
37
|
}
|
|
36
38
|
);
|
|
37
|
-
const p =
|
|
38
|
-
return /* @__PURE__ */
|
|
39
|
-
/* @__PURE__ */
|
|
40
|
-
|
|
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
|
-
|
|
45
|
-
|
|
49
|
+
Y as TokenAmount,
|
|
50
|
+
m as TokenAmountTest
|
|
46
51
|
};
|
|
@@ -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;
|