@gearbox-protocol/ui-kit 4.0.0-next.27 → 4.0.0-next.28

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 (27) hide show
  1. package/dist/cjs/components/base/apy-breakdown-body/apy-breakdown-body.cjs +1 -0
  2. package/dist/cjs/components/base/apy-breakdown-body/index.cjs +1 -0
  3. package/dist/cjs/components/base/info-list/info-list.cjs +1 -1
  4. package/dist/cjs/components/base/pool-apy-breakdown-card/constants.cjs +1 -1
  5. package/dist/cjs/components/base/pool-apy-breakdown-card/pool-apy-breakdown-card.cjs +1 -1
  6. package/dist/cjs/components/base/strategy-apy-breakdown-card/strategy-apy-breakdown-card.cjs +1 -1
  7. package/dist/cjs/components/index.cjs +1 -1
  8. package/dist/cjs/components/yield-breakdown-tooltip/index.cjs +1 -1
  9. package/dist/cjs/components/yield-breakdown-tooltip/yield-breakdown-tooltip.cjs +1 -1
  10. package/dist/cjs/index.cjs +1 -1
  11. package/dist/esm/components/base/apy-breakdown-body/apy-breakdown-body.js +106 -0
  12. package/dist/esm/components/base/apy-breakdown-body/index.js +10 -0
  13. package/dist/esm/components/base/info-list/info-list.js +1 -1
  14. package/dist/esm/components/base/pool-apy-breakdown-card/constants.js +5 -2
  15. package/dist/esm/components/base/pool-apy-breakdown-card/pool-apy-breakdown-card.js +111 -57
  16. package/dist/esm/components/base/strategy-apy-breakdown-card/strategy-apy-breakdown-card.js +138 -209
  17. package/dist/esm/components/index.js +45 -44
  18. package/dist/esm/components/yield-breakdown-tooltip/index.js +2 -1
  19. package/dist/esm/components/yield-breakdown-tooltip/yield-breakdown-tooltip.js +136 -156
  20. package/dist/esm/index.js +191 -190
  21. package/dist/globals.css +1 -1
  22. package/dist/types/components/base/apy-breakdown-body/apy-breakdown-body.d.ts +42 -0
  23. package/dist/types/components/base/apy-breakdown-body/index.d.ts +2 -0
  24. package/dist/types/components/base/pool-apy-breakdown-card/constants.d.ts +3 -0
  25. package/dist/types/components/base/pool-apy-breakdown-card/pool-apy-breakdown-card.d.ts +9 -7
  26. package/dist/types/components/yield-breakdown-tooltip/yield-breakdown-tooltip.d.ts +23 -3
  27. package/package.json +1 -1
@@ -1,204 +1,184 @@
1
- import { jsxs as a, jsx as e, Fragment as N } 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 P } from "../tooltip/simple-tooltip.js";
1
+ import { jsx as e, jsxs as c, Fragment as A } from "react/jsx-runtime";
2
+ import { APY_BREAKDOWN_TOOLTIP_WIDTH as B, ApyBreakdownBody as v, formatBreakdownRate as u, ApyBreakdownRow as y, periodMessageId as w, ApyBreakdownDivider as h } from "../base/apy-breakdown-body/apy-breakdown-body.js";
3
+ import { PoolApyBreakdownCard as b } from "../base/pool-apy-breakdown-card/pool-apy-breakdown-card.js";
4
+ import { PointsIcon as I } from "../points-icon/points-icon.js";
5
+ import { TokenIcon as P } from "../token-icon/token-icon.js";
6
+ import { SimpleTooltip as T } from "../tooltip/simple-tooltip.js";
5
7
  import "../tooltip/tooltip.js";
6
- import { FormattedMessageTyped as s } from "../typed-intl/index.js";
7
- import "react";
8
- import { tokenRewardsOf as T, pointProgramsOf as $, totalApyOf as j } from "../../utils/apy-breakdown.js";
9
- import "@gearbox-protocol/sdk/onchain";
10
- import { bpsToPercent as R } from "../../utils/bps.js";
11
- import { cn as f } from "../../utils/cn.js";
12
- import "sonner";
13
- import { formatLeverage as S } from "../../utils/format-leverage.js";
14
- import { formatCompactPercent as C } from "../../utils/format-money.js";
15
- import "@gearbox-protocol/sdk/common-utils";
16
- import "luxon";
17
- import "../../utils/z-index.js";
18
- function p(o) {
19
- const n = R(o), r = C(Math.abs(n));
20
- return n < 0 ? `-${r}` : r;
8
+ import { FormattedMessageTyped as d } from "../typed-intl/index.js";
9
+ import { tokenRewardsOf as O, pointProgramsOf as R, totalApyOf as x } from "../../utils/apy-breakdown.js";
10
+ import { formatLeverage as N } from "../../utils/format-leverage.js";
11
+ function S({
12
+ title: t,
13
+ children: l,
14
+ placement: s = "left",
15
+ open: a,
16
+ className: i,
17
+ triggerClassName: n
18
+ }) {
19
+ return /* @__PURE__ */ e(
20
+ T,
21
+ {
22
+ placement: s,
23
+ triangle: !1,
24
+ type: "modal-tooltip",
25
+ minWidth: B,
26
+ maxWidth: B,
27
+ title: t,
28
+ open: a,
29
+ className: i,
30
+ triggerClassName: n,
31
+ children: l
32
+ }
33
+ );
21
34
  }
22
- function m(o, n, r) {
23
- return o === "7d" ? r : n;
35
+ function H({
36
+ supplyApy: t,
37
+ maxLeverage: l,
38
+ collateralApy: s,
39
+ borrowApy: a,
40
+ quotaRate: i,
41
+ period: n,
42
+ children: r,
43
+ className: m,
44
+ open: g
45
+ }) {
46
+ const p = l !== void 0 && l > 0;
47
+ return /* @__PURE__ */ e(
48
+ S,
49
+ {
50
+ placement: "bottom",
51
+ title: /* @__PURE__ */ e("span", { className: m, children: r }),
52
+ triggerClassName: m,
53
+ open: g,
54
+ children: p ? /* @__PURE__ */ e(
55
+ W,
56
+ {
57
+ supplyApy: t,
58
+ maxLeverage: l,
59
+ collateralApy: s,
60
+ borrowApy: a,
61
+ quotaRate: i,
62
+ period: n
63
+ }
64
+ ) : /* @__PURE__ */ e(b, { data: t, period: n })
65
+ }
66
+ );
24
67
  }
25
- function Z({
26
- supplyApy: o,
27
- maxLeverage: n,
28
- collateralApy: r,
29
- borrowApy: g,
30
- quotaRate: b,
31
- period: l,
32
- children: h,
33
- className: w
68
+ function W({
69
+ supplyApy: t,
70
+ maxLeverage: l,
71
+ collateralApy: s,
72
+ borrowApy: a,
73
+ quotaRate: i,
74
+ period: n
34
75
  }) {
35
- const d = n !== void 0 && n > 0, i = d ? r : r ?? o, k = i ? T(i) : [], v = $(o), x = j(o), u = g != null || b != null ? -((g ?? 0) + (b ?? 0)) : void 0, y = v.filter((t) => t.multiplier != null), B = /* @__PURE__ */ a(
36
- "div",
76
+ const r = s, m = r ? O(r) : [], g = R(t), p = x(t), f = a != null || i != null ? -((a ?? 0) + (i ?? 0)) : void 0, k = g.filter((o) => o.multiplier != null);
77
+ return /* @__PURE__ */ c(
78
+ v,
37
79
  {
38
- className: f(
39
- "flex w-[400px] max-w-[calc(100vw-32px)] flex-col gap-4 p-4",
40
- "rounded-xl",
41
- "bg-card text-card-foreground",
42
- "border border-border",
43
- "shadow-[0_4px_14px_rgba(0,0,0,0.15)]",
44
- "text-left font-normal"
80
+ title: /* @__PURE__ */ e(
81
+ d,
82
+ {
83
+ messageId: w(
84
+ n,
85
+ "components.yieldBreakdown.titleNetAtLeverage",
86
+ "components.yieldBreakdown.titleNetAtLeverage7d"
87
+ ),
88
+ values: { leverage: N(l) }
89
+ }
45
90
  ),
91
+ chip: u(p),
92
+ chipPositive: p > 0,
46
93
  children: [
47
- /* @__PURE__ */ a("div", { className: "flex h-6 items-center justify-between gap-3", children: [
48
- /* @__PURE__ */ e("span", { className: "text-base font-semibold leading-4 text-foreground", children: d ? /* @__PURE__ */ e(
49
- s,
50
- {
51
- messageId: m(
52
- l,
53
- "components.yieldBreakdown.titleNetAtLeverage",
54
- "components.yieldBreakdown.titleNetAtLeverage7d"
55
- ),
56
- values: {
57
- leverage: S(n)
58
- }
59
- }
60
- ) : /* @__PURE__ */ e(
61
- s,
62
- {
63
- messageId: m(
64
- l,
65
- "components.yieldBreakdown.titleNet",
66
- "components.yieldBreakdown.titleNet7d"
67
- )
68
- }
69
- ) }),
70
- /* @__PURE__ */ e(
71
- "span",
72
- {
73
- className: f(
74
- "rounded-md px-2 py-0.5 text-sm font-semibold tabular-nums",
75
- x > 0 ? "bg-success/20 text-success" : "bg-muted text-muted-foreground"
76
- ),
77
- children: p(x)
78
- }
79
- )
80
- ] }),
81
- i?.organicApy != null && /* @__PURE__ */ e(
82
- c,
94
+ r?.organicApy != null ? /* @__PURE__ */ e(
95
+ y,
83
96
  {
84
- muted: i.organicApy < 0,
97
+ muted: r.organicApy < 0,
85
98
  label: /* @__PURE__ */ e(
86
- s,
99
+ d,
87
100
  {
88
- messageId: d ? m(
89
- l,
101
+ messageId: w(
102
+ n,
90
103
  "components.yieldBreakdown.collateralApy",
91
104
  "components.yieldBreakdown.collateralApy7d"
92
- ) : m(
93
- l,
94
- "components.yieldBreakdown.baseApy",
95
- "components.yieldBreakdown.baseApy7d"
96
105
  )
97
106
  }
98
107
  ),
99
- value: p(i.organicApy)
108
+ value: u(r.organicApy)
100
109
  }
110
+ ) : null,
111
+ m.map(
112
+ (o) => o.supplyApr == null ? null : /* @__PURE__ */ e(
113
+ y,
114
+ {
115
+ muted: o.supplyApr < 0,
116
+ label: /* @__PURE__ */ c("span", { className: "inline-flex items-center gap-1.5", children: [
117
+ /* @__PURE__ */ e("span", { children: /* @__PURE__ */ e(
118
+ d,
119
+ {
120
+ messageId: "components.apyParts.extraAPY",
121
+ values: { symbol: o.token.symbol }
122
+ }
123
+ ) }),
124
+ /* @__PURE__ */ e(P, { token: o.token, size: 20 })
125
+ ] }),
126
+ value: u(o.supplyApr)
127
+ },
128
+ `incentive-${o.token.address}-${o.supplyApr}`
129
+ )
101
130
  ),
102
- k.map((t) => t.supplyApr == null ? null : /* @__PURE__ */ e(
103
- c,
104
- {
105
- muted: t.supplyApr < 0,
106
- label: /* @__PURE__ */ a("span", { className: "inline-flex items-center gap-1.5", children: [
107
- /* @__PURE__ */ e("span", { children: /* @__PURE__ */ e(
108
- s,
109
- {
110
- messageId: "components.apyParts.extraAPY",
111
- values: { symbol: t.token.symbol }
112
- }
113
- ) }),
114
- /* @__PURE__ */ e(I, { token: t.token, size: 20 })
115
- ] }),
116
- value: p(t.supplyApr)
117
- },
118
- `incentive-${t.token.address}-${t.supplyApr}`
119
- )),
120
- d && u != null && /* @__PURE__ */ e(
121
- c,
131
+ f != null ? /* @__PURE__ */ e(
132
+ y,
122
133
  {
123
- muted: u < 0,
134
+ muted: f < 0,
124
135
  label: /* @__PURE__ */ e(
125
- s,
136
+ d,
126
137
  {
127
- messageId: m(
128
- l,
138
+ messageId: w(
139
+ n,
129
140
  "components.yieldBreakdown.borrowRate",
130
141
  "components.yieldBreakdown.borrowRate7d"
131
142
  )
132
143
  }
133
144
  ),
134
- value: p(u)
145
+ value: u(f)
135
146
  }
136
- ),
137
- y.length > 0 && /* @__PURE__ */ a(N, { children: [
138
- /* @__PURE__ */ e("div", { className: "h-px w-full bg-divider" }),
139
- y.map((t) => /* @__PURE__ */ e(
140
- c,
147
+ ) : null,
148
+ k.length > 0 ? /* @__PURE__ */ c(A, { children: [
149
+ /* @__PURE__ */ e(h, {}),
150
+ k.map((o) => /* @__PURE__ */ e(
151
+ y,
141
152
  {
142
- label: /* @__PURE__ */ a("span", { className: "inline-flex items-center gap-1.5", children: [
153
+ label: /* @__PURE__ */ c("span", { className: "inline-flex items-center gap-1.5", children: [
143
154
  /* @__PURE__ */ e("span", { children: /* @__PURE__ */ e(
144
- s,
155
+ d,
145
156
  {
146
157
  messageId: "components.yieldBreakdown.programPoints",
147
- values: { name: t.name }
158
+ values: { name: o.name }
148
159
  }
149
160
  ) }),
150
161
  /* @__PURE__ */ e(
151
- A,
162
+ I,
152
163
  {
153
164
  reward: {
154
- name: t.name,
155
- type: t.id
165
+ name: o.name,
166
+ type: o.id
156
167
  },
157
168
  size: 20
158
169
  }
159
170
  )
160
171
  ] }),
161
- value: `${t.multiplier}×`
172
+ value: `${o.multiplier}×`
162
173
  },
163
- `points-${t.id}`
174
+ `points-${o.id}`
164
175
  ))
165
- ] })
176
+ ] }) : null
166
177
  ]
167
178
  }
168
179
  );
169
- return /* @__PURE__ */ e(
170
- P,
171
- {
172
- placement: "bottom",
173
- triangle: !1,
174
- type: "modal-tooltip",
175
- minWidth: "100%",
176
- maxWidth: "100%",
177
- title: /* @__PURE__ */ e("span", { className: w, children: h }),
178
- triggerClassName: w,
179
- children: B
180
- }
181
- );
182
- }
183
- function c({
184
- label: o,
185
- value: n,
186
- muted: r = !1
187
- }) {
188
- return /* @__PURE__ */ a("div", { className: "flex h-6 items-center justify-between gap-3 text-sm leading-5", children: [
189
- /* @__PURE__ */ e("span", { className: "min-w-0 font-normal text-muted-foreground", children: o }),
190
- /* @__PURE__ */ e(
191
- "span",
192
- {
193
- className: f(
194
- "shrink-0 font-semibold tabular-nums",
195
- r ? "text-muted-foreground" : "text-foreground"
196
- ),
197
- children: n
198
- }
199
- )
200
- ] });
201
180
  }
202
181
  export {
203
- Z as YieldBreakdownTooltip
182
+ S as ApyBreakdownTooltip,
183
+ H as YieldBreakdownTooltip
204
184
  };