@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.
Files changed (26) hide show
  1. package/dist/cjs/components/base/stat-badge/constants.cjs +1 -1
  2. package/dist/cjs/components/base/stat-badge/stat-badge.cjs +1 -1
  3. package/dist/cjs/components/base/strategy-apy-breakdown-card/strategy-apy-breakdown-card.cjs +1 -1
  4. package/dist/cjs/components/base/tabber/tabber.cjs +1 -1
  5. package/dist/cjs/components/yield-breakdown-tooltip/yield-breakdown-tooltip.cjs +1 -1
  6. package/dist/cjs/index.cjs +1 -1
  7. package/dist/cjs/locale/en.json.cjs +1 -1
  8. package/dist/cjs/utils/index.cjs +1 -1
  9. package/dist/cjs/utils/strategy-apy.cjs +1 -0
  10. package/dist/esm/components/base/stat-badge/constants.js +1 -0
  11. package/dist/esm/components/base/stat-badge/stat-badge.js +87 -52
  12. package/dist/esm/components/base/strategy-apy-breakdown-card/strategy-apy-breakdown-card.js +130 -110
  13. package/dist/esm/components/base/tabber/tabber.js +67 -64
  14. package/dist/esm/components/yield-breakdown-tooltip/yield-breakdown-tooltip.js +20 -19
  15. package/dist/esm/index.js +234 -230
  16. package/dist/esm/locale/en.json.js +2 -1
  17. package/dist/esm/utils/index.js +64 -60
  18. package/dist/esm/utils/strategy-apy.js +41 -0
  19. package/dist/types/components/base/stat-badge/constants.d.ts +1 -0
  20. package/dist/types/components/base/stat-badge/stat-badge.d.ts +11 -1
  21. package/dist/types/components/base/strategy-apy-breakdown-card/strategy-apy-breakdown-card.d.ts +12 -0
  22. package/dist/types/components/base/tabber/tabber.d.ts +2 -2
  23. package/dist/types/locale/en.json.d.ts +2 -1
  24. package/dist/types/utils/index.d.ts +1 -0
  25. package/dist/types/utils/strategy-apy.d.ts +37 -0
  26. package/package.json +1 -1
@@ -1,124 +1,127 @@
1
- import { jsx as r, jsxs as u } from "react/jsx-runtime";
2
- import { createContext as O, useContext as E, useMemo as x, Children as B, useRef as T, useEffect as q, isValidElement as N } from "react";
3
- import { SectionHeading as D } from "../section-heading/section-heading.js";
4
- import { Stack as f } from "../stack/stack.js";
5
- import { StickyBar as F } from "../sticky-bar/sticky-bar.js";
6
- import { useTitleText as R } from "../text/use-title-text.js";
7
- import { TabItem as M, TabControl as P } from "../../tab-control/tab-control.js";
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 V } from "./use-detail-scroll-spy.js";
10
- const j = O({});
11
- function k({
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: c = o,
15
- actions: a,
14
+ heading: s = o,
15
+ actions: c,
16
16
  children: m,
17
- hideHeading: l = !1
17
+ hideHeading: a = !1
18
18
  }) {
19
- const i = E(j), n = R(), s = !l;
19
+ const l = q(k), i = j(), n = !a;
20
20
  return /* @__PURE__ */ r(
21
21
  "section",
22
22
  {
23
- ref: i[e],
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(f, { gap: "md", children: [
28
- s || a ? /* @__PURE__ */ u("div", { className: "flex items-center justify-between gap-3", children: [
29
- s ? /* @__PURE__ */ r(D, { children: n(c) }) : /* @__PURE__ */ r("span", {}),
30
- a
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
- k.displayName = "TabberSection";
37
+ A.displayName = "TabberSection";
38
38
  function g(e) {
39
- return N(e) && e.type === k;
39
+ return R(e) && e.type === A;
40
40
  }
41
- function W({
41
+ function z({
42
42
  item: e,
43
43
  ...o
44
44
  }) {
45
- return /* @__PURE__ */ u("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(P, { ...o, showBorder: !0 }) }),
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 z({
50
+ function G({
51
51
  children: e,
52
52
  observeKey: o,
53
- initialSection: c,
54
- testId: a,
53
+ initialSection: s,
54
+ testId: c,
55
55
  mobileManagePane: m
56
56
  }) {
57
- const l = x(
58
- () => B.toArray(e).filter(g),
57
+ const a = d(
58
+ () => N.toArray(e).filter(g),
59
59
  [e]
60
- ), i = l.map((t) => t.props.id).join("|"), n = x(
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
- ), s = T({}), d = x(() => {
66
+ ), w = T({}), f = d(() => {
64
67
  const t = {
65
- ...s.current
68
+ ...w.current
66
69
  };
67
- for (const y of n)
68
- t[y] === void 0 && (t[y] = { current: null });
69
- return s.current = t, t;
70
- }, [n]), A = R(), { activeSection: p, scrollToSection: b } = V(
71
- d,
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
- ), h = T(!1), w = T(o);
75
- q(() => {
76
- if (o !== w.current && (w.current = o, h.current = !1), h.current || !o) return;
77
- const t = c ?? n[0];
78
- h.current = !0, !(t === void 0 || t === n[0]) && d[t] !== void 0 && requestAnimationFrame(() => {
79
- b(t);
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, c, b, n, d]);
82
- const I = l.map((t) => ({
84
+ }, [o, s, h, n, f]);
85
+ const H = l.map((t) => ({
83
86
  id: t.props.id,
84
87
  item: /* @__PURE__ */ r(
85
- M,
88
+ P,
86
89
  {
87
- selected: p === t.props.id,
88
- label: A(t.props.title)
90
+ selected: b === t.props.id,
91
+ label: I(t.props.title)
89
92
  }
90
93
  )
91
- })), C = B.toArray(e), v = C.filter(
94
+ })), C = N.toArray(e), y = C.filter(
92
95
  (t) => g(t) && t.props.beforeBar === !0
93
- ), H = C.filter(
96
+ ), O = C.filter(
94
97
  (t) => !(g(t) && t.props.beforeBar === !0)
95
98
  );
96
- return /* @__PURE__ */ r(f, { gap: "lg", "data-testid": a ?? S.root, children: /* @__PURE__ */ u(j.Provider, { value: d, children: [
97
- v.length > 0 ? /* @__PURE__ */ r(f, { gap: "xl", children: v }) : null,
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(F, { testId: S.bar, children: /* @__PURE__ */ r(
100
- W,
102
+ /* @__PURE__ */ r(M, { testId: S.bar, children: /* @__PURE__ */ r(
103
+ z,
101
104
  {
102
105
  state: {
103
- id: p,
104
- index: n.indexOf(p),
106
+ id: b,
107
+ index: n.indexOf(b),
105
108
  handleTabChange: (t) => {
106
- b(t);
109
+ h(t);
107
110
  }
108
111
  },
109
- tabs: I,
112
+ tabs: H,
110
113
  item: null
111
114
  }
112
115
  ) }),
113
- /* @__PURE__ */ r(f, { gap: "xl", children: H })
116
+ /* @__PURE__ */ r(u, { gap: "xl", children: O })
114
117
  ] }) });
115
118
  }
116
- function $(e) {
117
- return N(e) && e.type === z;
119
+ function K(e) {
120
+ return R(e) && e.type === G;
118
121
  }
119
122
  export {
120
- z as Tabber,
121
- k as TabberSection,
123
+ G as Tabber,
124
+ A as TabberSection,
122
125
  S as TabberTest,
123
- $ as isTabber
126
+ K as isTabber
124
127
  };
@@ -1,25 +1,26 @@
1
- import { jsxs as a, jsx as e, Fragment as k } from "react/jsx-runtime";
2
- import { PointsIcon as N } from "../points-icon/points-icon.js";
3
- import { TokenIcon as P } from "../token-icon/token-icon.js";
4
- import { SimpleTooltip as A } from "../tooltip/simple-tooltip.js";
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 I, pointProgramsOf as B, totalApyOf as T } from "../../utils/apy-breakdown.js";
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 $ } from "../../utils/bps.js";
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 j } from "../../utils/format-leverage.js";
14
- import { formatCompactPercent as R } from "../../utils/format-money.js";
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 = $(n), r = R(Math.abs(o));
20
+ const o = j(n), r = C(Math.abs(o));
20
21
  return o < 0 ? `-${r}` : r;
21
22
  }
22
- function U({
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, w = I(l), y = B(n), b = T(n), d = c != null || u != null ? -((c ?? 0) + (u ?? 0)) : void 0, x = y.filter((t) => t.multiplier != null), v = /* @__PURE__ */ a(
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: j(o)
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
- w.map((t) => t.supplyApr == null ? null : /* @__PURE__ */ e(
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(P, { token: t.token, size: 20 })
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(k, { children: [
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
- N,
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
- A,
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: v
141
+ children: N
141
142
  }
142
143
  );
143
144
  }
@@ -161,5 +162,5 @@ function m({
161
162
  ] });
162
163
  }
163
164
  export {
164
- U as YieldBreakdownTooltip
165
+ L as YieldBreakdownTooltip
165
166
  };