@gearbox-protocol/ui-kit 4.0.0-next.47 → 4.0.0-next.48
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/health-factor-block/health-factor-block.cjs +1 -1
- package/dist/cjs/components/health-factor/health-factor.cjs +1 -1
- package/dist/esm/components/base/health-factor-block/health-factor-block.js +40 -45
- package/dist/esm/components/health-factor/health-factor.js +27 -24
- package/dist/types/components/base/health-factor-block/health-factor-block.d.ts +4 -4
- package/dist/types/components/health-factor/health-factor.d.ts +10 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),v=require("../text/use-title-text.cjs"),d=require("../../fadeout-loading/fadeout-loading.cjs"),u=require("../../health-factor/health-factor.cjs"),h=require("../../typed-intl/index.cjs"),T=require("../../vertical-indicator/vertical-indicator.cjs"),t=require("./constants.cjs");function _({healthFactor:o,healthFactorTo:s,debt:c,debtTo:m,approximate:l,zone:n,isLoading:r,title:i,tip:x,testId:p}){const F=v.useTitleText(),a=s!==void 0;return e.jsx(T.VerticalIndicator,{align:"center",dimPreviousValue:!1,"data-testid":p??t.HealthFactorBlockTest.root,label:i!==void 0?F(i):e.jsx(h.FormattedMessageTyped,{messageId:"components.healthFactorBlock.label"}),tip:x??e.jsx(h.FormattedMessageTyped,{messageId:"components.healthFactorBlock.tip"}),value:e.jsx(d.FadeoutLoading,{loading:r,children:o===void 0?e.jsx("span",{"data-testid":t.HealthFactorBlockTest.value,children:"—"}):e.jsx("span",{className:"inline-flex items-center","data-testid":t.HealthFactorBlockTest.value,children:e.jsx(u.HealthFactor,{value:o,debt:c,zone:a?void 0:n,approximate:l&&!a})})}),valueTo:a?e.jsx(d.FadeoutLoading,{loading:r,children:e.jsx("span",{className:"inline-flex items-center","data-testid":t.HealthFactorBlockTest.valueTo,children:e.jsx(u.HealthFactor,{value:s,debt:m??c,zone:n,approximate:l})})}):void 0})}exports.HealthFactorBlockTest=t.HealthFactorBlockTest;exports.HealthFactorBlock=_;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),u=require("@gearbox-protocol/sdk/onchain"),g=require("class-variance-authority");require("react");const j=require("../../utils/cn.cjs");require("sonner");require("luxon");require("../../utils/z-index.cjs");const a=require("../status-elements/status-elements.cjs"),l=15e3,d=11e3,
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),u=require("@gearbox-protocol/sdk/onchain"),g=require("class-variance-authority");require("react");const j=require("../../utils/cn.cjs");require("sonner");const O=require("../../utils/format.cjs");require("luxon");require("../../utils/z-index.cjs");const a=require("../status-elements/status-elements.cjs"),l=15e3,d=11e3,D=10500,m=t=>{if(t)return t>=l?"good":t>d?"medium":t>D?"bad":t>u.PERCENTAGE_FACTOR?"critical":"liquidation"},N=g.cva("inline-flex items-center font-medium [text-decoration:inherit]",{variants:{zone:{good:"text-success",medium:"text-warning",bad:"text-destructive",critical:"text-destructive",liquidation:"text-liquidation",unset:"[color:unset]"}}});function b({value:t,debt:i,decimals:x=3,zone:e,zoneType:s="color",approximate:q,className:v,..._}){const n=i!==void 0&&i===0n,f=!n&&s==="color",h=!n&&e&&s==="dot",F=!n&&e&&s==="bars",o=f?e===void 0?m(t):e:void 0,c=o===void 0?void 0:o===null?"unset":o,H=()=>{if(n)return"N/A";const A=Number(t);return u.formatPercentage(A,x)};return r.jsxs("span",{className:j.cn(N(c!==void 0?{zone:c}:{}),v),..._,children:[F&&r.jsx("span",{className:"mr-6 shrink-0",children:r.jsx(a.StatusBars,{zone:e})}),q&&!n?r.jsx("span",{className:"mr-0.5",children:O.APPROXIMATE_SYMBOL}):null,H(),h&&r.jsx("span",{className:"ml-1.5",children:r.jsx(a.HealthDot,{zone:e})})]})}exports.BAD_HF=d;exports.GOOD_HF=l;exports.HealthFactor=b;exports.getHFZones=m;
|
|
@@ -1,72 +1,67 @@
|
|
|
1
|
-
import { jsx as e
|
|
2
|
-
import { useTitleText as
|
|
1
|
+
import { jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { useTitleText as g } from "../text/use-title-text.js";
|
|
3
3
|
import { FadeoutLoading as c } from "../../fadeout-loading/fadeout-loading.js";
|
|
4
|
-
import { HealthFactor as
|
|
5
|
-
import { FormattedMessageTyped as
|
|
6
|
-
import { VerticalIndicator as
|
|
7
|
-
import { APPROXIMATE_SYMBOL as v } from "../../../utils/format.js";
|
|
4
|
+
import { HealthFactor as m } from "../../health-factor/health-factor.js";
|
|
5
|
+
import { FormattedMessageTyped as p } from "../../typed-intl/index.js";
|
|
6
|
+
import { VerticalIndicator as x } from "../../vertical-indicator/vertical-indicator.js";
|
|
8
7
|
import { HealthFactorBlockTest as t } from "./constants.js";
|
|
9
|
-
function
|
|
10
|
-
healthFactor:
|
|
11
|
-
healthFactorTo:
|
|
12
|
-
debt:
|
|
13
|
-
debtTo:
|
|
8
|
+
function N({
|
|
9
|
+
healthFactor: a,
|
|
10
|
+
healthFactorTo: i,
|
|
11
|
+
debt: l,
|
|
12
|
+
debtTo: u,
|
|
14
13
|
approximate: r,
|
|
15
|
-
zone:
|
|
16
|
-
isLoading:
|
|
14
|
+
zone: n,
|
|
15
|
+
isLoading: s,
|
|
17
16
|
title: d,
|
|
18
|
-
tip:
|
|
19
|
-
testId:
|
|
17
|
+
tip: v,
|
|
18
|
+
testId: f
|
|
20
19
|
}) {
|
|
21
|
-
const
|
|
20
|
+
const h = g(), o = i !== void 0;
|
|
22
21
|
return /* @__PURE__ */ e(
|
|
23
|
-
|
|
22
|
+
x,
|
|
24
23
|
{
|
|
25
24
|
align: "center",
|
|
26
25
|
dimPreviousValue: !1,
|
|
27
|
-
"data-testid":
|
|
28
|
-
label: d !== void 0 ?
|
|
29
|
-
tip:
|
|
30
|
-
value: /* @__PURE__ */ e(c, { loading:
|
|
26
|
+
"data-testid": f ?? t.root,
|
|
27
|
+
label: d !== void 0 ? h(d) : /* @__PURE__ */ e(p, { messageId: "components.healthFactorBlock.label" }),
|
|
28
|
+
tip: v ?? /* @__PURE__ */ e(p, { messageId: "components.healthFactorBlock.tip" }),
|
|
29
|
+
value: /* @__PURE__ */ e(c, { loading: s, children: a === void 0 ? /* @__PURE__ */ e("span", { "data-testid": t.value, children: "—" }) : /* @__PURE__ */ e(
|
|
31
30
|
"span",
|
|
32
31
|
{
|
|
33
32
|
className: "inline-flex items-center",
|
|
34
33
|
"data-testid": t.value,
|
|
35
|
-
children:
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
)
|
|
45
|
-
]
|
|
34
|
+
children: /* @__PURE__ */ e(
|
|
35
|
+
m,
|
|
36
|
+
{
|
|
37
|
+
value: a,
|
|
38
|
+
debt: l,
|
|
39
|
+
zone: o ? void 0 : n,
|
|
40
|
+
approximate: r && !o
|
|
41
|
+
}
|
|
42
|
+
)
|
|
46
43
|
}
|
|
47
44
|
) }),
|
|
48
|
-
valueTo:
|
|
45
|
+
valueTo: o ? /* @__PURE__ */ e(c, { loading: s, children: /* @__PURE__ */ e(
|
|
49
46
|
"span",
|
|
50
47
|
{
|
|
51
48
|
className: "inline-flex items-center",
|
|
52
49
|
"data-testid": t.valueTo,
|
|
53
|
-
children:
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
)
|
|
63
|
-
]
|
|
50
|
+
children: /* @__PURE__ */ e(
|
|
51
|
+
m,
|
|
52
|
+
{
|
|
53
|
+
value: i,
|
|
54
|
+
debt: u ?? l,
|
|
55
|
+
zone: n,
|
|
56
|
+
approximate: r
|
|
57
|
+
}
|
|
58
|
+
)
|
|
64
59
|
}
|
|
65
60
|
) }) : void 0
|
|
66
61
|
}
|
|
67
62
|
);
|
|
68
63
|
}
|
|
69
64
|
export {
|
|
70
|
-
|
|
65
|
+
N as HealthFactorBlock,
|
|
71
66
|
t as HealthFactorBlockTest
|
|
72
67
|
};
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { PERCENTAGE_FACTOR as
|
|
3
|
-
import { cva as
|
|
1
|
+
import { jsxs as h, jsx as n } from "react/jsx-runtime";
|
|
2
|
+
import { PERCENTAGE_FACTOR as A, formatPercentage as N } from "@gearbox-protocol/sdk/onchain";
|
|
3
|
+
import { cva as C } from "class-variance-authority";
|
|
4
4
|
import "react";
|
|
5
|
-
import { cn as
|
|
5
|
+
import { cn as F } from "../../utils/cn.js";
|
|
6
6
|
import "sonner";
|
|
7
|
+
import { APPROXIMATE_SYMBOL as H } from "../../utils/format.js";
|
|
7
8
|
import "luxon";
|
|
8
9
|
import "../../utils/z-index.js";
|
|
9
|
-
import { StatusBars as
|
|
10
|
-
const
|
|
10
|
+
import { StatusBars as g, HealthDot as D } from "../status-elements/status-elements.js";
|
|
11
|
+
const O = 15e3, _ = 11e3, b = 10500, w = (t) => {
|
|
11
12
|
if (t)
|
|
12
|
-
return t >=
|
|
13
|
-
},
|
|
13
|
+
return t >= O ? "good" : t > _ ? "medium" : t > b ? "bad" : t > A ? "critical" : "liquidation";
|
|
14
|
+
}, B = C(
|
|
14
15
|
"inline-flex items-center font-medium [text-decoration:inherit]",
|
|
15
16
|
{
|
|
16
17
|
variants: {
|
|
@@ -25,41 +26,43 @@ const A = 15e3, D = 11e3, b = 10500, w = (t) => {
|
|
|
25
26
|
}
|
|
26
27
|
}
|
|
27
28
|
);
|
|
28
|
-
function
|
|
29
|
+
function S({
|
|
29
30
|
value: t,
|
|
30
31
|
debt: s,
|
|
31
32
|
decimals: c = 3,
|
|
32
33
|
zone: o,
|
|
33
|
-
zoneType:
|
|
34
|
-
|
|
34
|
+
zoneType: i = "color",
|
|
35
|
+
approximate: m,
|
|
36
|
+
className: l,
|
|
35
37
|
...u
|
|
36
38
|
}) {
|
|
37
|
-
const r = s !== void 0 && s === 0n, d = !r &&
|
|
39
|
+
const r = s !== void 0 && s === 0n, d = !r && i === "color", f = !r && o && i === "dot", p = !r && o && i === "bars", e = d ? o === void 0 ? w(t) : o : void 0, a = e === void 0 ? void 0 : e === null ? "unset" : e, v = () => {
|
|
38
40
|
if (r) return "N/A";
|
|
39
|
-
const
|
|
40
|
-
return
|
|
41
|
+
const x = Number(t);
|
|
42
|
+
return N(x, c);
|
|
41
43
|
};
|
|
42
|
-
return /* @__PURE__ */
|
|
44
|
+
return /* @__PURE__ */ h(
|
|
43
45
|
"span",
|
|
44
46
|
{
|
|
45
|
-
className:
|
|
46
|
-
|
|
47
|
+
className: F(
|
|
48
|
+
B(
|
|
47
49
|
a !== void 0 ? { zone: a } : {}
|
|
48
50
|
),
|
|
49
|
-
|
|
51
|
+
l
|
|
50
52
|
),
|
|
51
53
|
...u,
|
|
52
54
|
children: [
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
55
|
+
p && /* @__PURE__ */ n("span", { className: "mr-6 shrink-0", children: /* @__PURE__ */ n(g, { zone: o }) }),
|
|
56
|
+
m && !r ? /* @__PURE__ */ n("span", { className: "mr-0.5", children: H }) : null,
|
|
57
|
+
v(),
|
|
58
|
+
f && /* @__PURE__ */ n("span", { className: "ml-1.5", children: /* @__PURE__ */ n(D, { zone: o }) })
|
|
56
59
|
]
|
|
57
60
|
}
|
|
58
61
|
);
|
|
59
62
|
}
|
|
60
63
|
export {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
+
_ as BAD_HF,
|
|
65
|
+
O as GOOD_HF,
|
|
66
|
+
S as HealthFactor,
|
|
64
67
|
w as getHFZones
|
|
65
68
|
};
|
|
@@ -14,10 +14,10 @@ export interface HealthFactorBlockProps {
|
|
|
14
14
|
/** Debt after the operation (defaults to `debt`). */
|
|
15
15
|
readonly debtTo?: bigint;
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
17
|
+
* Marks the figure as projected rather than promised, with a leading `≈` in
|
|
18
|
+
* the factor's own colour. Only the projected side is marked: on a
|
|
19
|
+
* `from → to` row the "from" is where the account stands now, which is
|
|
20
|
+
* measured, not estimated.
|
|
21
21
|
*/
|
|
22
22
|
readonly approximate?: boolean;
|
|
23
23
|
/** Pre-computed zone; if not set, derived from the value. */
|
|
@@ -23,6 +23,15 @@ export interface HealthFactorProps extends React.HTMLAttributes<HTMLSpanElement>
|
|
|
23
23
|
* @default "color"
|
|
24
24
|
*/
|
|
25
25
|
zoneType?: "color" | "bars" | "dot";
|
|
26
|
+
/**
|
|
27
|
+
* Marks the figure as projected rather than measured, with a leading `≈`.
|
|
28
|
+
*
|
|
29
|
+
* Drawn here, inside the zone-colored span, because the symbol belongs to the
|
|
30
|
+
* number: a caller placing it beside this component leaves it uncolored while
|
|
31
|
+
* the value it qualifies is red. Suppressed on a zero debt, where there is no
|
|
32
|
+
* factor to approximate — only "N/A".
|
|
33
|
+
*/
|
|
34
|
+
approximate?: boolean;
|
|
26
35
|
}
|
|
27
36
|
/**
|
|
28
37
|
* HealthFactor — primitive under {@link HealthFactorBlock} (zones / bars / dot).
|
|
@@ -41,4 +50,4 @@ export interface HealthFactorProps extends React.HTMLAttributes<HTMLSpanElement>
|
|
|
41
50
|
* <HealthFactor value={15000} debt={0n} /> // "N/A"
|
|
42
51
|
* ```
|
|
43
52
|
*/
|
|
44
|
-
export declare function HealthFactor({ value, debt, decimals, zone, zoneType, className, ...props }: HealthFactorProps): React.JSX.Element;
|
|
53
|
+
export declare function HealthFactor({ value, debt, decimals, zone, zoneType, approximate, className, ...props }: HealthFactorProps): React.JSX.Element;
|