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

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,4 +1,4 @@
1
- import { jsx as n, jsxs as m, Fragment as p } from "react/jsx-runtime";
1
+ import { jsx as e, jsxs as m, Fragment as p } from "react/jsx-runtime";
2
2
  import { Stack as h } from "../stack/stack.js";
3
3
  import "../../help-tip/help-tip.js";
4
4
  import "react";
@@ -7,26 +7,28 @@ import "@gearbox-protocol/sdk/onchain";
7
7
  import "clsx";
8
8
  import "tailwind-merge";
9
9
  import "sonner";
10
+ import { APPROXIMATE_SYMBOL as f } from "../../../utils/format.js";
10
11
  import "luxon";
11
12
  import "../../../utils/z-index.js";
12
13
  import "../../points-icon/points-icon.js";
13
14
  import { TokenBigint as d } from "../values/scalars.js";
14
15
  import "../../badge/badge.js";
15
16
  import "../../badge/chip.js";
16
- import { ShortString as f } from "../../short-string/short-string.js";
17
- import { TokenSymbol as u } from "../../token-symbol/token-symbol.js";
18
- import { Typography as k } from "../../typography/typography.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";
19
20
  import { PositionAssetsTest as c } from "./constants.js";
20
- const v = 1, g = 20;
21
- function Y({
21
+ const g = 1, y = 20;
22
+ function I({
22
23
  assets: s,
23
- to: e,
24
+ to: r,
24
25
  empty: a,
25
- testId: i
26
+ approximate: l,
27
+ testId: o
26
28
  }) {
27
- const t = y(s, e), r = e !== void 0;
28
- return /* @__PURE__ */ n(h, { gap: "sm", align: "end", "data-testid": i ?? c.root, children: t.length === 0 ? a !== void 0 && /* @__PURE__ */ n(
29
- k,
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
32
  {
31
33
  variant: "caption",
32
34
  color: "secondary",
@@ -34,63 +36,64 @@ function Y({
34
36
  "data-testid": c.empty,
35
37
  children: a
36
38
  }
37
- ) : t.map((o) => /* @__PURE__ */ m(
39
+ ) : n.map((t) => /* @__PURE__ */ m(
38
40
  "span",
39
41
  {
40
42
  className: "flex items-center gap-2",
41
43
  "data-testid": c.row,
42
44
  children: [
43
- /* @__PURE__ */ n(u, { size: 20, token: o.token }),
45
+ /* @__PURE__ */ e(k, { size: 20, token: t.token }),
44
46
  /* @__PURE__ */ m("span", { className: "flex items-center", children: [
45
- r && /* @__PURE__ */ m(p, { children: [
46
- /* @__PURE__ */ n("span", { className: "text-secondary-foreground line-through [&_*]:text-secondary-foreground [&_*]:line-through", children: /* @__PURE__ */ n(
47
+ i && /* @__PURE__ */ m(p, { children: [
48
+ /* @__PURE__ */ e("span", { className: "text-secondary-foreground line-through [&_*]:text-secondary-foreground [&_*]:line-through", children: /* @__PURE__ */ e(
47
49
  d,
48
50
  {
49
- data: o.value,
50
- token: o.token,
51
+ data: t.value,
52
+ token: t.token,
51
53
  showSymbol: !1
52
54
  }
53
55
  ) }),
54
- /* @__PURE__ */ n("span", { className: "px-1.5 text-gray-70", children: "→" })
56
+ /* @__PURE__ */ e("span", { className: "px-1.5 text-gray-70", children: "→" })
55
57
  ] }),
56
- /* @__PURE__ */ n(
58
+ l ? /* @__PURE__ */ e("span", { children: f }) : null,
59
+ /* @__PURE__ */ e(
57
60
  d,
58
61
  {
59
- data: r ? o.valueTo : o.value,
60
- token: o.token,
62
+ data: i ? t.valueTo : t.value,
63
+ token: t.token,
61
64
  showSymbol: !1
62
65
  }
63
66
  ),
64
- /* @__PURE__ */ n(f, { className: "ml-1", maxLength: g, children: o.token.symbol })
67
+ /* @__PURE__ */ e(u, { className: "ml-1", maxLength: y, children: t.token.symbol })
65
68
  ] })
66
69
  ]
67
70
  },
68
- o.token.address
71
+ t.token.address
69
72
  )) });
70
73
  }
71
- function y(s, e) {
72
- const a = /* @__PURE__ */ new Map(), i = (t, r) => {
73
- const o = t.token.address.toLowerCase(), l = a.get(o);
74
- a.set(o, {
75
- token: l?.token ?? t.token,
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, {
78
+ token: t?.token ?? o.token,
76
79
  // a token only the other side holds is a zero here, not a gap
77
- value: r === "from" ? t.value : l?.value ?? 0n,
78
- valueTo: r === "to" ? t.value : l?.valueTo ?? 0n,
79
- worth: x(l?.worth, t.valueUsd)
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)
80
83
  });
81
84
  };
82
- for (const t of s ?? []) i(t, "from");
83
- for (const t of e ?? []) i(t, "to");
84
- return [...a.values()].filter((t) => t.worth === null || t.worth >= v).sort(
85
- (t, r) => (r.worth ?? 0) - (t.worth ?? 0) || // a tie has to break the same way every render, or the rows drift
86
- t.token.address.localeCompare(r.token.address)
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)
87
90
  );
88
91
  }
89
- function x(s, e) {
90
- return s === void 0 ? e : s === null || e === null ? null : Math.max(s, e);
92
+ function x(s, r) {
93
+ return s === void 0 ? r : s === null || r === null ? null : Math.max(s, r);
91
94
  }
92
95
  export {
93
- Y as PositionAssets,
96
+ I as PositionAssets,
94
97
  c as PositionAssetsTest,
95
- y as visibleAssets
98
+ S as visibleAssets
96
99
  };
@@ -1,60 +1,68 @@
1
- import { jsx as t, jsxs as c } from "react/jsx-runtime";
2
- import { useTitleText as T } from "../text/use-title-text.js";
3
- import { FadeoutLoading as l } from "../../fadeout-loading/fadeout-loading.js";
4
- import { HealthDot as f } from "../../status-elements/status-elements.js";
5
- import { FormattedMessageTyped as m } from "../../typed-intl/index.js";
6
- import { VerticalIndicator as h } from "../../vertical-indicator/vertical-indicator.js";
7
- import { ttlLeft as g, getTTLZones as x } from "../../../utils/ttl.js";
8
- import { TimeToLiquidationBlockTest as r } from "./constants.js";
1
+ import { jsx as t, jsxs as m, Fragment as f } from "react/jsx-runtime";
2
+ import { useTitleText as h } from "../text/use-title-text.js";
3
+ import { FadeoutLoading as s } from "../../fadeout-loading/fadeout-loading.js";
4
+ import { HealthDot as g } from "../../status-elements/status-elements.js";
5
+ import { FormattedMessageTyped as u } from "../../typed-intl/index.js";
6
+ import { VerticalIndicator as L } from "../../vertical-indicator/vertical-indicator.js";
7
+ import { APPROXIMATE_SYMBOL as I } from "../../../utils/format.js";
8
+ import { ttlLeft as x, getTTLZones as B } from "../../../utils/ttl.js";
9
+ import { TimeToLiquidationBlockTest as a } from "./constants.js";
9
10
  function j({
10
11
  data: o,
11
12
  dataTo: n,
12
- zone: a,
13
+ approximate: r,
14
+ zone: l,
13
15
  isLoading: e,
14
16
  title: i,
15
- tip: s,
16
- testId: v
17
+ tip: v,
18
+ testId: p
17
19
  }) {
18
- const p = T(), d = n !== void 0;
20
+ const T = h(), d = n !== void 0;
19
21
  return /* @__PURE__ */ t(
20
- h,
22
+ L,
21
23
  {
22
24
  align: "center",
23
25
  dimPreviousValue: !1,
24
- "data-testid": v ?? r.root,
25
- label: i !== void 0 ? p(i) : /* @__PURE__ */ t(m, { messageId: "components.timeToLiquidationBlock.label" }),
26
- tip: s ?? /* @__PURE__ */ t(m, { messageId: "components.timeToLiquidationBlock.tip" }),
27
- value: /* @__PURE__ */ t(l, { loading: e, children: /* @__PURE__ */ t(
28
- u,
26
+ "data-testid": p ?? a.root,
27
+ label: i !== void 0 ? T(i) : /* @__PURE__ */ t(u, { messageId: "components.timeToLiquidationBlock.label" }),
28
+ tip: v ?? /* @__PURE__ */ t(u, { messageId: "components.timeToLiquidationBlock.tip" }),
29
+ value: /* @__PURE__ */ t(s, { loading: e, children: /* @__PURE__ */ t(
30
+ c,
29
31
  {
30
32
  milliseconds: o,
31
- zone: d ? void 0 : a,
32
- testId: r.value
33
+ approximate: r,
34
+ zone: d ? void 0 : l,
35
+ testId: a.value
33
36
  }
34
37
  ) }),
35
- valueTo: d ? /* @__PURE__ */ t(l, { loading: e, children: /* @__PURE__ */ t(
36
- u,
38
+ valueTo: d ? /* @__PURE__ */ t(s, { loading: e, children: /* @__PURE__ */ t(
39
+ c,
37
40
  {
38
41
  milliseconds: n ?? null,
39
- zone: a,
40
- testId: r.valueTo
42
+ approximate: r,
43
+ zone: l,
44
+ testId: a.valueTo
41
45
  }
42
46
  ) }) : void 0
43
47
  }
44
48
  );
45
49
  }
46
- function u({
50
+ function c({
47
51
  milliseconds: o,
48
- zone: n,
49
- testId: a
52
+ approximate: n,
53
+ zone: r,
54
+ testId: l
50
55
  }) {
51
- const e = o == null ? void 0 : g(o), i = n ?? (o == null ? void 0 : x(o));
52
- return /* @__PURE__ */ c("span", { className: "inline-flex items-center", "data-testid": a, children: [
53
- o === void 0 ? "—" : o === null ? "N/A" : e?.months !== void 0 ? `${e.months}mo` : e?.day !== void 0 ? `${e.day}d` : "<1d",
54
- o != null && i ? /* @__PURE__ */ t("span", { className: "ml-1.5", children: /* @__PURE__ */ t(f, { zone: i }) }) : null
56
+ const e = o == null ? void 0 : x(o), i = r ?? (o == null ? void 0 : B(o));
57
+ return /* @__PURE__ */ m("span", { className: "inline-flex items-center", "data-testid": l, children: [
58
+ o === void 0 ? "—" : o === null ? "N/A" : /* @__PURE__ */ m(f, { children: [
59
+ n ? /* @__PURE__ */ t("span", { className: "mr-0.5", children: I }) : null,
60
+ e?.months !== void 0 ? `${e.months}mo` : e?.day !== void 0 ? `${e.day}d` : "<1d"
61
+ ] }),
62
+ o != null && i ? /* @__PURE__ */ t("span", { className: "ml-1.5", children: /* @__PURE__ */ t(g, { zone: i }) }) : null
55
63
  ] });
56
64
  }
57
65
  export {
58
66
  j as TimeToLiquidationBlock,
59
- r as TimeToLiquidationBlockTest
67
+ a as TimeToLiquidationBlockTest
60
68
  };
@@ -1,4 +1,4 @@
1
- import { jsxs as i, Fragment as d, jsx as n } from "react/jsx-runtime";
1
+ import { jsxs as i, Fragment as d, jsx as o } from "react/jsx-runtime";
2
2
  import { cva as y } from "class-variance-authority";
3
3
  import { FadeoutLoading as g } from "../../../../fadeout-loading/fadeout-loading.js";
4
4
  import { TokenIcon as v } from "../../../../token-icon/token-icon.js";
@@ -7,11 +7,12 @@ import "react";
7
7
  import "@gearbox-protocol/sdk/onchain";
8
8
  import { cn as h } from "../../../../../utils/cn.js";
9
9
  import "sonner";
10
- import { formatMoney as k } from "../../../../../utils/format-money.js";
10
+ import { APPROXIMATE_SYMBOL as k } from "../../../../../utils/format.js";
11
+ import { formatMoney as N } from "../../../../../utils/format-money.js";
11
12
  import "luxon";
12
13
  import "../../../../../utils/z-index.js";
13
- import { TransactionConfirmAmountFieldTest as N } from "./constants.js";
14
- const T = "≈", b = y(
14
+ import { TransactionConfirmAmountFieldTest as T } from "./constants.js";
15
+ const b = y(
15
16
  "flex w-full items-center justify-between bg-gray-20 px-4 py-3",
16
17
  {
17
18
  variants: {
@@ -29,59 +30,59 @@ const T = "≈", b = y(
29
30
  defaultVariants: { position: "first", size: "md" }
30
31
  }
31
32
  );
32
- function S(o) {
33
- if (o.primaryAmount !== void 0)
33
+ function S(n) {
34
+ if (n.primaryAmount !== void 0)
34
35
  return {
35
- primaryAmount: o.primaryAmount,
36
- secondaryAmount: o.secondaryAmount
36
+ primaryAmount: n.primaryAmount,
37
+ secondaryAmount: n.secondaryAmount
37
38
  };
38
- const { amount: t } = o;
39
+ const { amount: t } = n;
39
40
  return {
40
41
  primaryAmount: { value: t?.value, token: t?.token },
41
42
  secondaryAmount: { valueUSD: t?.valueUsd ?? void 0 }
42
43
  };
43
44
  }
44
- function V(o) {
45
+ function E(n) {
45
46
  const {
46
47
  label: t,
47
48
  loading: l = !1,
48
49
  position: p,
49
- size: c = "md",
50
- maxLength: u,
50
+ size: u = "md",
51
+ maxLength: c,
51
52
  approximate: f
52
- } = o, { isApproximate: a = !1, approximateSymbol: m = T } = f || {}, { primaryAmount: e, secondaryAmount: r } = S(o), x = e && "node" in e ? e.node : /* @__PURE__ */ i(d, { children: [
53
- e.token && /* @__PURE__ */ n(v, { token: e.token, size: 16 }),
53
+ } = n, { isApproximate: m = !1, approximateSymbol: a = k } = f || {}, { primaryAmount: e, secondaryAmount: r } = S(n), x = e && "node" in e ? e.node : /* @__PURE__ */ i(d, { children: [
54
+ e.token && /* @__PURE__ */ o(v, { token: e.token, size: 16 }),
54
55
  /* @__PURE__ */ i("span", { children: [
55
- a && /* @__PURE__ */ n("span", { children: m }),
56
- /* @__PURE__ */ n(
56
+ m && /* @__PURE__ */ o("span", { children: a }),
57
+ /* @__PURE__ */ o(
57
58
  A,
58
59
  {
59
60
  value: e?.value,
60
61
  token: e.token,
61
- maxLength: u
62
+ maxLength: c
62
63
  }
63
64
  )
64
65
  ] })
65
66
  ] }), s = r && "node" in r ? r.node : r?.valueUSD ? /* @__PURE__ */ i(d, { children: [
66
- a && /* @__PURE__ */ n("span", { children: m }),
67
- k(r.valueUSD)
67
+ m && /* @__PURE__ */ o("span", { children: a }),
68
+ N(r.valueUSD)
68
69
  ] }) : null;
69
70
  return /* @__PURE__ */ i(
70
71
  "div",
71
72
  {
72
- className: h(b({ position: p, size: c })),
73
- "data-testid": N.root,
73
+ className: h(b({ position: p, size: u })),
74
+ "data-testid": T.root,
74
75
  children: [
75
- /* @__PURE__ */ n("span", { className: "text-sm font-medium text-foreground", children: t }),
76
+ /* @__PURE__ */ o("span", { className: "text-sm font-medium text-foreground", children: t }),
76
77
  /* @__PURE__ */ i("div", { className: "flex flex-col items-end gap-0.5", children: [
77
- /* @__PURE__ */ n(g, { loading: l, children: /* @__PURE__ */ n("span", { className: "inline-flex items-center gap-1.5 text-sm font-medium text-foreground", children: x }) }),
78
- s && /* @__PURE__ */ n("span", { className: "text-xs leading-[130%] text-secondary-foreground", children: s })
78
+ /* @__PURE__ */ o(g, { loading: l, children: /* @__PURE__ */ o("span", { className: "inline-flex items-center gap-1.5 text-sm font-medium text-foreground", children: x }) }),
79
+ s && /* @__PURE__ */ o("span", { className: "text-xs leading-[130%] text-secondary-foreground", children: s })
79
80
  ] })
80
81
  ]
81
82
  }
82
83
  );
83
84
  }
84
85
  export {
85
- V as TransactionConfirmAmountField,
86
+ E as TransactionConfirmAmountField,
86
87
  S as resolveAmountSlots
87
88
  };