@gearbox-protocol/ui-kit 4.0.0-next.16 → 4.0.0-next.17

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.
Files changed (28) hide show
  1. package/dist/cjs/components/base/index.cjs +1 -1
  2. package/dist/cjs/components/base/info-list/info-list.cjs +1 -1
  3. package/dist/cjs/components/base/position-assets/constants.cjs +1 -0
  4. package/dist/cjs/components/base/position-assets/index.cjs +1 -0
  5. package/dist/cjs/components/base/position-assets/position-assets.cjs +1 -0
  6. package/dist/cjs/components/base/values/scalars.cjs +1 -1
  7. package/dist/cjs/components/checkbox/checkbox-labeled.cjs +1 -1
  8. package/dist/cjs/components/client-adapters/styled-rounded-image/styled-rounded-image.cjs +1 -1
  9. package/dist/cjs/components/index.cjs +1 -1
  10. package/dist/cjs/components/with-copy/with-copy.cjs +1 -1
  11. package/dist/cjs/index.cjs +1 -1
  12. package/dist/esm/components/base/index.js +112 -108
  13. package/dist/esm/components/base/info-list/info-list.js +7 -6
  14. package/dist/esm/components/base/position-assets/constants.js +8 -0
  15. package/dist/esm/components/base/position-assets/index.js +6 -0
  16. package/dist/esm/components/base/position-assets/position-assets.js +73 -0
  17. package/dist/esm/components/base/values/scalars.js +52 -33
  18. package/dist/esm/components/checkbox/checkbox-labeled.js +1 -1
  19. package/dist/esm/components/client-adapters/styled-rounded-image/styled-rounded-image.js +1 -1
  20. package/dist/esm/components/index.js +662 -658
  21. package/dist/esm/components/with-copy/with-copy.js +1 -1
  22. package/dist/esm/index.js +852 -848
  23. package/dist/types/components/base/index.d.ts +1 -0
  24. package/dist/types/components/base/position-assets/constants.d.ts +5 -0
  25. package/dist/types/components/base/position-assets/index.d.ts +2 -0
  26. package/dist/types/components/base/position-assets/position-assets.d.ts +49 -0
  27. package/dist/types/components/base/values/scalars.d.ts +4 -0
  28. package/package.json +1 -1
@@ -0,0 +1,73 @@
1
+ import { jsx as i, jsxs as p } from "react/jsx-runtime";
2
+ import { Stack as d } from "../stack/stack.js";
3
+ import "react";
4
+ import "@gearbox-protocol/sdk";
5
+ import "clsx";
6
+ import "tailwind-merge";
7
+ import "sonner";
8
+ import "@gearbox-protocol/sdk/common-utils";
9
+ import "luxon";
10
+ import "../../../utils/z-index.js";
11
+ import "../../points-icon/points-icon.js";
12
+ import { TokenBigint as c } from "../values/scalars.js";
13
+ import "../../badge/badge.js";
14
+ import "../../badge/chip.js";
15
+ import "react-intl";
16
+ import { TokenSymbol as f } from "../../token-symbol/token-symbol.js";
17
+ import { Typography as u } from "../../typography/typography.js";
18
+ import { PositionAssetsTest as m } from "./constants.js";
19
+ const k = 1;
20
+ function _({
21
+ assets: r,
22
+ against: e,
23
+ empty: s,
24
+ testId: n
25
+ }) {
26
+ const t = h(r, e);
27
+ return /* @__PURE__ */ i(d, { gap: "sm", align: "end", "data-testid": n ?? m.root, children: t.length === 0 ? s !== void 0 && /* @__PURE__ */ i(
28
+ u,
29
+ {
30
+ variant: "caption",
31
+ color: "secondary",
32
+ as: "div",
33
+ "data-testid": m.empty,
34
+ children: s
35
+ }
36
+ ) : t.map((o) => /* @__PURE__ */ p(
37
+ "span",
38
+ {
39
+ className: "flex items-center gap-2",
40
+ "data-testid": m.row,
41
+ children: [
42
+ /* @__PURE__ */ i(f, { size: 20, token: o.token }),
43
+ /* @__PURE__ */ i(c, { data: o.value, token: o.token })
44
+ ]
45
+ },
46
+ o.token.address
47
+ )) });
48
+ }
49
+ function h(r, e) {
50
+ const s = /* @__PURE__ */ new Map(), n = (t, o) => {
51
+ const l = t.token.address.toLowerCase(), a = s.get(l);
52
+ s.set(l, {
53
+ token: a?.token ?? t.token,
54
+ // a token the other side alone holds is a zero here, not a gap
55
+ value: o ? t.value : a?.value ?? 0n,
56
+ worth: v(a?.worth, t.valueUsd)
57
+ });
58
+ };
59
+ for (const t of r ?? []) n(t, !0);
60
+ for (const t of e ?? []) n(t, !1);
61
+ return [...s.values()].filter((t) => t.worth === null || t.worth >= k).sort(
62
+ (t, o) => (o.worth ?? 0) - (t.worth ?? 0) || // a tie has to break the same way on both sides, or the rows drift
63
+ t.token.address.localeCompare(o.token.address)
64
+ );
65
+ }
66
+ function v(r, e) {
67
+ return r === void 0 ? e : r === null || e === null ? null : Math.max(r, e);
68
+ }
69
+ export {
70
+ _ as PositionAssets,
71
+ m as PositionAssetsTest,
72
+ h as visibleAssets
73
+ };
@@ -1,63 +1,82 @@
1
- import { jsx as e } from "react/jsx-runtime";
2
- import { CompoundAPY as s } from "../../compound-apy/compound-apy.js";
1
+ import { jsx as r, jsxs as s } from "react/jsx-runtime";
2
+ import { formatUnits as m } from "viem";
3
+ import { CompoundAPY as p } from "../../compound-apy/compound-apy.js";
4
+ import { SimpleTooltip as u } from "../../tooltip/simple-tooltip.js";
5
+ import "../../tooltip/tooltip.js";
3
6
  import "react";
4
7
  import "@gearbox-protocol/sdk";
5
8
  import { cn as a } from "../../../utils/cn.js";
6
9
  import "sonner";
7
- import { formatLeverage as c } from "../../../utils/format-leverage.js";
8
- import { formatPercentAmount as m, formatMoney as l } from "../../../utils/format-money.js";
10
+ import { formatAssetAmount as c } from "../../../utils/format-asset-amount.js";
11
+ import { formatLeverage as d } from "../../../utils/format-leverage.js";
12
+ import { formatPercentAmount as f, formatMoney as h } from "../../../utils/format-money.js";
9
13
  import "@gearbox-protocol/sdk/common-utils";
10
14
  import "luxon";
11
15
  import "../../../utils/z-index.js";
12
- import { ValueTest as r } from "./constants.js";
13
- const d = "—";
14
- function i() {
15
- return /* @__PURE__ */ e("span", { "data-testid": r.placeholder, children: d });
16
+ import { ValueTest as e } from "./constants.js";
17
+ const v = "—";
18
+ function n() {
19
+ return /* @__PURE__ */ r("span", { "data-testid": e.placeholder, children: v });
16
20
  }
17
- function o(t) {
18
- return `${m(t / 100, 2)}%`;
21
+ function l(t) {
22
+ return `${f(t / 100, 2)}%`;
19
23
  }
20
- function P({ data: t }) {
21
- return t === void 0 ? /* @__PURE__ */ e(i, {}) : typeof t == "number" ? /* @__PURE__ */ e("span", { "data-testid": r.apy, children: o(t) }) : /* @__PURE__ */ e("span", { "data-testid": r.apy, children: /* @__PURE__ */ e(s, { apy: t }) });
24
+ function E({ data: t }) {
25
+ return t === void 0 ? /* @__PURE__ */ r(n, {}) : typeof t == "number" ? /* @__PURE__ */ r("span", { "data-testid": e.apy, children: l(t) }) : /* @__PURE__ */ r("span", { "data-testid": e.apy, children: /* @__PURE__ */ r(p, { apy: t }) });
22
26
  }
23
- function $({
27
+ function H({
24
28
  data: t
25
29
  }) {
26
- return t == null ? /* @__PURE__ */ e(i, {}) : /* @__PURE__ */ e("span", { "data-testid": r.usd, children: l(t) });
30
+ return t == null ? /* @__PURE__ */ r(n, {}) : /* @__PURE__ */ r("span", { "data-testid": e.usd, children: h(t) });
27
31
  }
28
- function z({
32
+ function N({
29
33
  data: t
30
34
  }) {
31
- return t === void 0 ? /* @__PURE__ */ e(i, {}) : /* @__PURE__ */ e("span", { "data-testid": r.leverage, children: `${c(t)}x` });
35
+ return t === void 0 ? /* @__PURE__ */ r(n, {}) : /* @__PURE__ */ r("span", { "data-testid": e.leverage, children: `${d(t)}x` });
32
36
  }
33
37
  function w({
34
38
  data: t
35
39
  }) {
36
- return t === void 0 ? /* @__PURE__ */ e(i, {}) : /* @__PURE__ */ e("span", { "data-testid": r.utilization, children: o(t) });
40
+ return t === void 0 ? /* @__PURE__ */ r(n, {}) : /* @__PURE__ */ r("span", { "data-testid": e.utilization, children: l(t) });
37
41
  }
38
- function B({
42
+ function D({
39
43
  data: t
40
44
  }) {
41
45
  if (t === void 0)
42
- return /* @__PURE__ */ e(i, {});
43
- const n = t < 1e4 ? "text-destructive" : t < 11e3 ? "text-warning" : "text-success";
44
- return /* @__PURE__ */ e("span", { "data-testid": r.healthFactor, className: a(n), children: (t / 1e4).toFixed(2) });
46
+ return /* @__PURE__ */ r(n, {});
47
+ const i = t < 1e4 ? "text-destructive" : t < 11e3 ? "text-warning" : "text-success";
48
+ return /* @__PURE__ */ r("span", { "data-testid": e.healthFactor, className: a(i), children: (t / 1e4).toFixed(2) });
45
49
  }
46
- function C({
50
+ function M({
47
51
  data: t,
48
- token: n
52
+ token: i
49
53
  }) {
50
- if (t === void 0 || n === void 0)
51
- return /* @__PURE__ */ e(i, {});
52
- const u = Number(t) / 10 ** n.decimals;
53
- return /* @__PURE__ */ e("span", { "data-testid": r.tokenBigint, children: `${u.toLocaleString(void 0, { maximumFractionDigits: 6 })} ${n.symbol}` });
54
+ if (t === void 0 || i === void 0)
55
+ return /* @__PURE__ */ r(n, {});
56
+ const o = m(t, i.decimals);
57
+ return (
58
+ // `title` also keeps the amount where a hover tooltip cannot reach:
59
+ // keyboard, touch, and the browser's own find
60
+ /* @__PURE__ */ s("span", { "data-testid": e.tokenBigint, title: `${o} ${i.symbol}`, children: [
61
+ /* @__PURE__ */ r(
62
+ u,
63
+ {
64
+ placement: "top",
65
+ className: "break-all",
66
+ title: /* @__PURE__ */ r("span", { children: c(t, i.decimals) }),
67
+ children: /* @__PURE__ */ r("span", { children: o })
68
+ }
69
+ ),
70
+ ` ${i.symbol}`
71
+ ] })
72
+ );
54
73
  }
55
74
  export {
56
- P as ApyValue,
57
- B as HealthFactorValue,
58
- z as LeverageValue,
59
- C as TokenBigint,
60
- $ as UsdValue,
75
+ E as ApyValue,
76
+ D as HealthFactorValue,
77
+ N as LeverageValue,
78
+ M as TokenBigint,
79
+ H as UsdValue,
61
80
  w as UtilizationValue,
62
- o as bps
81
+ l as bps
63
82
  };
@@ -37,6 +37,7 @@ import "../simple-accordion/simple-accordion.js";
37
37
  import "../tip-card/tip-card.js";
38
38
  import "../typography/typography.js";
39
39
  import "../points-icon/points-icon.js";
40
+ import "viem";
40
41
  import "../vertical-indicator/vertical-indicator.js";
41
42
  import "../base/page-title/page-title.js";
42
43
  import "../detailed-page-title/detailed-page-title-copy-button.js";
@@ -72,7 +73,6 @@ import "../dialog/dialog-header.js";
72
73
  import "../dialog/dialog-title.js";
73
74
  import "../dialog/dialog-modal-container.js";
74
75
  import "../dialog/dialog-overlay.js";
75
- import "viem";
76
76
  import "../input/input.js";
77
77
  import { Label as k } from "../label/label.js";
78
78
  import "../simple-dropdown/simple-dropdown.js";
@@ -37,6 +37,7 @@ import "../../simple-accordion/simple-accordion.js";
37
37
  import "../../tip-card/tip-card.js";
38
38
  import "../../typography/typography.js";
39
39
  import "../../points-icon/points-icon.js";
40
+ import "viem";
40
41
  import "../../vertical-indicator/vertical-indicator.js";
41
42
  import "../../base/page-title/page-title.js";
42
43
  import "../../detailed-page-title/detailed-page-title-copy-button.js";
@@ -73,7 +74,6 @@ import "../../dialog/dialog-header.js";
73
74
  import "../../dialog/dialog-title.js";
74
75
  import "../../dialog/dialog-modal-container.js";
75
76
  import "../../dialog/dialog-overlay.js";
76
- import "viem";
77
77
  import "../../input/input.js";
78
78
  import "../../label/label.js";
79
79
  import "../../simple-dropdown/simple-dropdown.js";