@gearbox-protocol/ui-kit 4.0.0-next.15 → 4.0.0-next.16
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/stat-badge/constants.cjs +1 -1
- package/dist/cjs/components/base/stat-badge/stat-badge.cjs +1 -1
- package/dist/cjs/components/base/strategy-apy-breakdown-card/strategy-apy-breakdown-card.cjs +1 -1
- package/dist/cjs/components/base/tabber/tabber.cjs +1 -1
- package/dist/cjs/components/yield-breakdown-tooltip/yield-breakdown-tooltip.cjs +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/locale/en.json.cjs +1 -1
- package/dist/cjs/utils/index.cjs +1 -1
- package/dist/cjs/utils/strategy-apy.cjs +1 -0
- package/dist/esm/components/base/stat-badge/constants.js +1 -0
- package/dist/esm/components/base/stat-badge/stat-badge.js +87 -52
- package/dist/esm/components/base/strategy-apy-breakdown-card/strategy-apy-breakdown-card.js +130 -110
- package/dist/esm/components/base/tabber/tabber.js +67 -64
- package/dist/esm/components/yield-breakdown-tooltip/yield-breakdown-tooltip.js +20 -19
- package/dist/esm/index.js +234 -230
- package/dist/esm/locale/en.json.js +2 -1
- package/dist/esm/utils/index.js +64 -60
- package/dist/esm/utils/strategy-apy.js +41 -0
- package/dist/types/components/base/stat-badge/constants.d.ts +1 -0
- package/dist/types/components/base/stat-badge/stat-badge.d.ts +11 -1
- package/dist/types/components/base/strategy-apy-breakdown-card/strategy-apy-breakdown-card.d.ts +12 -0
- package/dist/types/components/base/tabber/tabber.d.ts +2 -2
- package/dist/types/locale/en.json.d.ts +2 -1
- package/dist/types/utils/index.d.ts +1 -0
- package/dist/types/utils/strategy-apy.d.ts +37 -0
- package/package.json +1 -1
|
@@ -1,124 +1,127 @@
|
|
|
1
|
-
import { jsx as r, jsxs as
|
|
2
|
-
import { createContext as
|
|
3
|
-
import { SectionHeading as
|
|
4
|
-
import { Stack as
|
|
5
|
-
import { StickyBar as
|
|
6
|
-
import { useTitleText as
|
|
7
|
-
import { TabItem as
|
|
1
|
+
import { jsx as r, jsxs as p } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as E, useContext as q, useMemo as d, Children as N, useRef as T, useEffect as D, isValidElement as R } from "react";
|
|
3
|
+
import { SectionHeading as F } from "../section-heading/section-heading.js";
|
|
4
|
+
import { Stack as u } from "../stack/stack.js";
|
|
5
|
+
import { StickyBar as M } from "../sticky-bar/sticky-bar.js";
|
|
6
|
+
import { useTitleText as j } from "../text/use-title-text.js";
|
|
7
|
+
import { TabItem as P, TabControl as V } from "../../tab-control/tab-control.js";
|
|
8
8
|
import { TabberTest as S } from "./constants.js";
|
|
9
|
-
import { useDetailScrollSpy as
|
|
10
|
-
const
|
|
11
|
-
function
|
|
9
|
+
import { useDetailScrollSpy as W } from "./use-detail-scroll-spy.js";
|
|
10
|
+
const k = E({});
|
|
11
|
+
function A({
|
|
12
12
|
id: e,
|
|
13
13
|
title: o,
|
|
14
|
-
heading:
|
|
15
|
-
actions:
|
|
14
|
+
heading: s = o,
|
|
15
|
+
actions: c,
|
|
16
16
|
children: m,
|
|
17
|
-
hideHeading:
|
|
17
|
+
hideHeading: a = !1
|
|
18
18
|
}) {
|
|
19
|
-
const
|
|
19
|
+
const l = q(k), i = j(), n = !a;
|
|
20
20
|
return /* @__PURE__ */ r(
|
|
21
21
|
"section",
|
|
22
22
|
{
|
|
23
|
-
ref:
|
|
23
|
+
ref: l[e],
|
|
24
24
|
className: "scroll-mt-28",
|
|
25
25
|
"data-scroll-section": e,
|
|
26
26
|
"data-testid": S.section,
|
|
27
|
-
children: /* @__PURE__ */ u
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
children: /* @__PURE__ */ p(u, { gap: "md", children: [
|
|
28
|
+
n || c ? /* @__PURE__ */ p("div", { className: "flex items-center justify-between gap-3", children: [
|
|
29
|
+
n ? /* @__PURE__ */ r(F, { children: i(s) }) : /* @__PURE__ */ r("span", {}),
|
|
30
|
+
c
|
|
31
31
|
] }) : null,
|
|
32
32
|
m
|
|
33
33
|
] })
|
|
34
34
|
}
|
|
35
35
|
);
|
|
36
36
|
}
|
|
37
|
-
|
|
37
|
+
A.displayName = "TabberSection";
|
|
38
38
|
function g(e) {
|
|
39
|
-
return
|
|
39
|
+
return R(e) && e.type === A;
|
|
40
40
|
}
|
|
41
|
-
function
|
|
41
|
+
function z({
|
|
42
42
|
item: e,
|
|
43
43
|
...o
|
|
44
44
|
}) {
|
|
45
|
-
return /* @__PURE__ */
|
|
46
|
-
/* @__PURE__ */ r("div", { className: "min-w-0 basis-0 grow pb-px", children: /* @__PURE__ */ r(
|
|
45
|
+
return /* @__PURE__ */ p("div", { className: "flex items-stretch overflow-x-auto overflow-y-hidden [&::-webkit-scrollbar]:h-0 [scrollbar-width:none]", children: [
|
|
46
|
+
/* @__PURE__ */ r("div", { className: "min-w-0 basis-0 grow pb-px", children: /* @__PURE__ */ r(V, { ...o, showBorder: !0 }) }),
|
|
47
47
|
e && /* @__PURE__ */ r("div", { className: "w-auto shrink-0 grow-0 basis-auto", children: e })
|
|
48
48
|
] });
|
|
49
49
|
}
|
|
50
|
-
function
|
|
50
|
+
function G({
|
|
51
51
|
children: e,
|
|
52
52
|
observeKey: o,
|
|
53
|
-
initialSection:
|
|
54
|
-
testId:
|
|
53
|
+
initialSection: s,
|
|
54
|
+
testId: c,
|
|
55
55
|
mobileManagePane: m
|
|
56
56
|
}) {
|
|
57
|
-
const
|
|
58
|
-
() =>
|
|
57
|
+
const a = d(
|
|
58
|
+
() => N.toArray(e).filter(g),
|
|
59
59
|
[e]
|
|
60
|
-
),
|
|
60
|
+
), l = d(
|
|
61
|
+
() => a.filter((t) => t.props.beforeBar !== !0),
|
|
62
|
+
[a]
|
|
63
|
+
), i = l.map((t) => t.props.id).join("|"), n = d(
|
|
61
64
|
() => i === "" ? [] : i.split("|"),
|
|
62
65
|
[i]
|
|
63
|
-
),
|
|
66
|
+
), w = T({}), f = d(() => {
|
|
64
67
|
const t = {
|
|
65
|
-
...
|
|
68
|
+
...w.current
|
|
66
69
|
};
|
|
67
|
-
for (const
|
|
68
|
-
t[
|
|
69
|
-
return
|
|
70
|
-
}, [n]),
|
|
71
|
-
|
|
70
|
+
for (const B of n)
|
|
71
|
+
t[B] === void 0 && (t[B] = { current: null });
|
|
72
|
+
return w.current = t, t;
|
|
73
|
+
}, [n]), I = j(), { activeSection: b, scrollToSection: h } = W(
|
|
74
|
+
f,
|
|
72
75
|
n,
|
|
73
76
|
o
|
|
74
|
-
),
|
|
75
|
-
|
|
76
|
-
if (o !==
|
|
77
|
-
const t =
|
|
78
|
-
|
|
79
|
-
|
|
77
|
+
), x = T(!1), v = T(o);
|
|
78
|
+
D(() => {
|
|
79
|
+
if (o !== v.current && (v.current = o, x.current = !1), x.current || !o) return;
|
|
80
|
+
const t = s ?? n[0];
|
|
81
|
+
x.current = !0, !(t === void 0 || t === n[0]) && f[t] !== void 0 && requestAnimationFrame(() => {
|
|
82
|
+
h(t);
|
|
80
83
|
});
|
|
81
|
-
}, [o,
|
|
82
|
-
const
|
|
84
|
+
}, [o, s, h, n, f]);
|
|
85
|
+
const H = l.map((t) => ({
|
|
83
86
|
id: t.props.id,
|
|
84
87
|
item: /* @__PURE__ */ r(
|
|
85
|
-
|
|
88
|
+
P,
|
|
86
89
|
{
|
|
87
|
-
selected:
|
|
88
|
-
label:
|
|
90
|
+
selected: b === t.props.id,
|
|
91
|
+
label: I(t.props.title)
|
|
89
92
|
}
|
|
90
93
|
)
|
|
91
|
-
})), C =
|
|
94
|
+
})), C = N.toArray(e), y = C.filter(
|
|
92
95
|
(t) => g(t) && t.props.beforeBar === !0
|
|
93
|
-
),
|
|
96
|
+
), O = C.filter(
|
|
94
97
|
(t) => !(g(t) && t.props.beforeBar === !0)
|
|
95
98
|
);
|
|
96
|
-
return /* @__PURE__ */ r(
|
|
97
|
-
|
|
99
|
+
return /* @__PURE__ */ r(u, { gap: "lg", "data-testid": c ?? S.root, children: /* @__PURE__ */ p(k.Provider, { value: f, children: [
|
|
100
|
+
y.length > 0 ? /* @__PURE__ */ r(u, { gap: "xl", children: y }) : null,
|
|
98
101
|
m,
|
|
99
|
-
/* @__PURE__ */ r(
|
|
100
|
-
|
|
102
|
+
/* @__PURE__ */ r(M, { testId: S.bar, children: /* @__PURE__ */ r(
|
|
103
|
+
z,
|
|
101
104
|
{
|
|
102
105
|
state: {
|
|
103
|
-
id:
|
|
104
|
-
index: n.indexOf(
|
|
106
|
+
id: b,
|
|
107
|
+
index: n.indexOf(b),
|
|
105
108
|
handleTabChange: (t) => {
|
|
106
|
-
|
|
109
|
+
h(t);
|
|
107
110
|
}
|
|
108
111
|
},
|
|
109
|
-
tabs:
|
|
112
|
+
tabs: H,
|
|
110
113
|
item: null
|
|
111
114
|
}
|
|
112
115
|
) }),
|
|
113
|
-
/* @__PURE__ */ r(
|
|
116
|
+
/* @__PURE__ */ r(u, { gap: "xl", children: O })
|
|
114
117
|
] }) });
|
|
115
118
|
}
|
|
116
|
-
function
|
|
117
|
-
return
|
|
119
|
+
function K(e) {
|
|
120
|
+
return R(e) && e.type === G;
|
|
118
121
|
}
|
|
119
122
|
export {
|
|
120
|
-
|
|
121
|
-
|
|
123
|
+
G as Tabber,
|
|
124
|
+
A as TabberSection,
|
|
122
125
|
S as TabberTest,
|
|
123
|
-
|
|
126
|
+
K as isTabber
|
|
124
127
|
};
|
|
@@ -1,25 +1,26 @@
|
|
|
1
|
-
import { jsxs as a, jsx as e, Fragment as
|
|
2
|
-
import { PointsIcon as
|
|
3
|
-
import { TokenIcon as
|
|
4
|
-
import { SimpleTooltip as
|
|
1
|
+
import { jsxs as a, jsx as e, Fragment as P } from "react/jsx-runtime";
|
|
2
|
+
import { PointsIcon as A } from "../points-icon/points-icon.js";
|
|
3
|
+
import { TokenIcon as I } from "../token-icon/token-icon.js";
|
|
4
|
+
import { SimpleTooltip as T } from "../tooltip/simple-tooltip.js";
|
|
5
5
|
import "../tooltip/tooltip.js";
|
|
6
6
|
import { FormattedMessageTyped as s } from "../typed-intl/index.js";
|
|
7
7
|
import "react";
|
|
8
|
-
import { tokenRewardsOf as
|
|
8
|
+
import { tokenRewardsOf as B, pointProgramsOf as R, totalApyOf as $ } from "../../utils/apy-breakdown.js";
|
|
9
9
|
import "@gearbox-protocol/sdk";
|
|
10
|
-
import { bpsToPercent as
|
|
10
|
+
import { bpsToPercent as j } from "../../utils/bps.js";
|
|
11
11
|
import { cn as p } from "../../utils/cn.js";
|
|
12
12
|
import "sonner";
|
|
13
|
-
import { formatLeverage as
|
|
14
|
-
import { formatCompactPercent as
|
|
13
|
+
import { formatLeverage as S } from "../../utils/format-leverage.js";
|
|
14
|
+
import { formatCompactPercent as C } from "../../utils/format-money.js";
|
|
15
|
+
import { strategyQuotaRate as O } from "../../utils/strategy-apy.js";
|
|
15
16
|
import "@gearbox-protocol/sdk/common-utils";
|
|
16
17
|
import "luxon";
|
|
17
18
|
import "../../utils/z-index.js";
|
|
18
19
|
function i(n) {
|
|
19
|
-
const o =
|
|
20
|
+
const o = j(n), r = C(Math.abs(o));
|
|
20
21
|
return o < 0 ? `-${r}` : r;
|
|
21
22
|
}
|
|
22
|
-
function
|
|
23
|
+
function L({
|
|
23
24
|
supplyApy: n,
|
|
24
25
|
maxLeverage: o,
|
|
25
26
|
collateralApy: r,
|
|
@@ -28,7 +29,7 @@ function U({
|
|
|
28
29
|
children: h,
|
|
29
30
|
className: f
|
|
30
31
|
}) {
|
|
31
|
-
const g = o !== void 0 && o > 0, l = r ?? n,
|
|
32
|
+
const g = o !== void 0 && o > 0, l = r ?? n, y = B(l), w = R(n), b = $(n), v = c != null || u != null, k = O({ additionalBorrowApy: u, maxLeverage: o }), d = v ? -((c ?? 0) + k) : void 0, x = w.filter((t) => t.multiplier != null), N = /* @__PURE__ */ a(
|
|
32
33
|
"div",
|
|
33
34
|
{
|
|
34
35
|
className: p(
|
|
@@ -46,7 +47,7 @@ function U({
|
|
|
46
47
|
{
|
|
47
48
|
messageId: "components.yieldBreakdown.titleNetAtLeverage",
|
|
48
49
|
values: {
|
|
49
|
-
leverage:
|
|
50
|
+
leverage: S(o)
|
|
50
51
|
}
|
|
51
52
|
}
|
|
52
53
|
) : /* @__PURE__ */ e(s, { messageId: "components.apyParts.totalAPY" }) }),
|
|
@@ -69,7 +70,7 @@ function U({
|
|
|
69
70
|
value: i(l.organicApy)
|
|
70
71
|
}
|
|
71
72
|
),
|
|
72
|
-
|
|
73
|
+
y.map((t) => t.supplyApr == null ? null : /* @__PURE__ */ e(
|
|
73
74
|
m,
|
|
74
75
|
{
|
|
75
76
|
muted: t.supplyApr < 0,
|
|
@@ -81,7 +82,7 @@ function U({
|
|
|
81
82
|
values: { symbol: t.token.symbol }
|
|
82
83
|
}
|
|
83
84
|
) }),
|
|
84
|
-
/* @__PURE__ */ e(
|
|
85
|
+
/* @__PURE__ */ e(I, { token: t.token, size: 20 })
|
|
85
86
|
] }),
|
|
86
87
|
value: i(t.supplyApr)
|
|
87
88
|
},
|
|
@@ -95,7 +96,7 @@ function U({
|
|
|
95
96
|
value: i(d)
|
|
96
97
|
}
|
|
97
98
|
),
|
|
98
|
-
x.length > 0 && /* @__PURE__ */ a(
|
|
99
|
+
x.length > 0 && /* @__PURE__ */ a(P, { children: [
|
|
99
100
|
/* @__PURE__ */ e("div", { className: "h-px w-full bg-divider" }),
|
|
100
101
|
x.map((t) => /* @__PURE__ */ e(
|
|
101
102
|
m,
|
|
@@ -109,7 +110,7 @@ function U({
|
|
|
109
110
|
}
|
|
110
111
|
) }),
|
|
111
112
|
/* @__PURE__ */ e(
|
|
112
|
-
|
|
113
|
+
A,
|
|
113
114
|
{
|
|
114
115
|
reward: {
|
|
115
116
|
name: t.name,
|
|
@@ -128,7 +129,7 @@ function U({
|
|
|
128
129
|
}
|
|
129
130
|
);
|
|
130
131
|
return /* @__PURE__ */ e(
|
|
131
|
-
|
|
132
|
+
T,
|
|
132
133
|
{
|
|
133
134
|
placement: "bottom",
|
|
134
135
|
triangle: !1,
|
|
@@ -137,7 +138,7 @@ function U({
|
|
|
137
138
|
maxWidth: "100%",
|
|
138
139
|
title: /* @__PURE__ */ e("span", { className: f, children: h }),
|
|
139
140
|
triggerClassName: f,
|
|
140
|
-
children:
|
|
141
|
+
children: N
|
|
141
142
|
}
|
|
142
143
|
);
|
|
143
144
|
}
|
|
@@ -161,5 +162,5 @@ function m({
|
|
|
161
162
|
] });
|
|
162
163
|
}
|
|
163
164
|
export {
|
|
164
|
-
|
|
165
|
+
L as YieldBreakdownTooltip
|
|
165
166
|
};
|