@gearbox-protocol/ui-kit 3.14.0-next.46 → 3.14.0-next.47
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 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),u=require("@gearbox-protocol/sdk"),h=require("class-variance-authority");require("react");const j=require("../../utils/cn.cjs");require("sonner");require("@gearbox-protocol/sdk/common-utils");require("luxon");require("../../utils/z-index.cjs");const a=require("../status-elements/status-elements.cjs"),l=15e3,d=11e3,A=10500,m=t=>{if(t)return t>=l?"good":t>d?"medium":t>A?"bad":t>u.PERCENTAGE_FACTOR?"critical":"liquidation"},D=h.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:q=3,zone:e,zoneType:s="color",className:x,...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,_=()=>{if(n)return"N/A";const g=Number(t);return u.formatPercentage(g,q)};return r.jsxs("span",{className:j.cn(D(c!==void 0?{zone:c}:{}),x),...v,children:[f&&r.jsx("span",{className:"mr-6 shrink-0",children:r.jsx(a.StatusBars,{zone:e})}),_(),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,17 +1,17 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { formatPercentage as
|
|
3
|
-
import { cva as
|
|
1
|
+
import { jsxs as x, jsx as i } from "react/jsx-runtime";
|
|
2
|
+
import { formatPercentage as h, PERCENTAGE_FACTOR as C } from "@gearbox-protocol/sdk";
|
|
3
|
+
import { cva as F } from "class-variance-authority";
|
|
4
4
|
import "react";
|
|
5
|
-
import { cn as
|
|
5
|
+
import { cn as H } from "../../utils/cn.js";
|
|
6
6
|
import "sonner";
|
|
7
7
|
import "@gearbox-protocol/sdk/common-utils";
|
|
8
8
|
import "luxon";
|
|
9
9
|
import "../../utils/z-index.js";
|
|
10
|
-
import { StatusBars as
|
|
11
|
-
const
|
|
10
|
+
import { StatusBars as N, HealthDot as g } from "../status-elements/status-elements.js";
|
|
11
|
+
const A = 15e3, D = 11e3, b = 10500, w = (t) => {
|
|
12
12
|
if (t)
|
|
13
|
-
return t >=
|
|
14
|
-
},
|
|
13
|
+
return t >= A ? "good" : t > D ? "medium" : t > b ? "bad" : t > C ? "critical" : "liquidation";
|
|
14
|
+
}, V = F(
|
|
15
15
|
"inline-flex items-center font-medium [text-decoration:inherit]",
|
|
16
16
|
{
|
|
17
17
|
variants: {
|
|
@@ -26,40 +26,41 @@ const g = 15e3, A = 11e3, H = 10500, N = (t) => {
|
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
);
|
|
29
|
-
function
|
|
29
|
+
function k({
|
|
30
30
|
value: t,
|
|
31
|
-
debt:
|
|
32
|
-
decimals:
|
|
31
|
+
debt: s,
|
|
32
|
+
decimals: c = 3,
|
|
33
33
|
zone: o,
|
|
34
|
-
zoneType:
|
|
34
|
+
zoneType: n = "color",
|
|
35
35
|
className: m,
|
|
36
36
|
...u
|
|
37
37
|
}) {
|
|
38
|
-
const
|
|
39
|
-
if (
|
|
40
|
-
const
|
|
41
|
-
return
|
|
38
|
+
const r = s !== void 0 && s === 0n, d = !r && n === "color", l = !r && o && n === "dot", f = !r && o && n === "bars", e = d ? o === void 0 ? w(t) : o : void 0, a = e === void 0 ? void 0 : e === null ? "unset" : e, p = () => {
|
|
39
|
+
if (r) return "N/A";
|
|
40
|
+
const v = Number(t);
|
|
41
|
+
return h(v, c);
|
|
42
42
|
};
|
|
43
|
-
return /* @__PURE__ */
|
|
43
|
+
return /* @__PURE__ */ x(
|
|
44
44
|
"span",
|
|
45
45
|
{
|
|
46
|
-
className:
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
className: H(
|
|
47
|
+
V(
|
|
48
|
+
a !== void 0 ? { zone: a } : {}
|
|
49
49
|
),
|
|
50
50
|
m
|
|
51
51
|
),
|
|
52
52
|
...u,
|
|
53
53
|
children: [
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
f && /* @__PURE__ */ i("span", { className: "mr-6 shrink-0", children: /* @__PURE__ */ i(N, { zone: o }) }),
|
|
55
|
+
p(),
|
|
56
|
+
l && /* @__PURE__ */ i("span", { className: "ml-1.5", children: /* @__PURE__ */ i(g, { zone: o }) })
|
|
56
57
|
]
|
|
57
58
|
}
|
|
58
59
|
);
|
|
59
60
|
}
|
|
60
61
|
export {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
62
|
+
D as BAD_HF,
|
|
63
|
+
A as GOOD_HF,
|
|
64
|
+
k as HealthFactor,
|
|
65
|
+
w as getHFZones
|
|
65
66
|
};
|
|
@@ -18,21 +18,24 @@ export interface HealthFactorProps extends React.HTMLAttributes<HTMLSpanElement>
|
|
|
18
18
|
/** Pre-computed zone; if not set, derived from value. */
|
|
19
19
|
zone?: HFZones | null;
|
|
20
20
|
/**
|
|
21
|
-
* How to indicate zone: "color" (text color only)
|
|
21
|
+
* How to indicate zone: "color" (text color only), "bars" (StatusBars before value),
|
|
22
|
+
* or "dot" (HealthDot after value, text stays default color).
|
|
22
23
|
* @default "color"
|
|
23
24
|
*/
|
|
24
|
-
zoneType?: "color" | "bars";
|
|
25
|
+
zoneType?: "color" | "bars" | "dot";
|
|
25
26
|
}
|
|
26
27
|
/**
|
|
27
28
|
* HealthFactor — displays health factor value with optional zone color or StatusBars.
|
|
28
29
|
*
|
|
29
30
|
* @usage
|
|
30
31
|
* Use for account/collateral health: value in basis points, zero debt shows "N/A".
|
|
31
|
-
* zoneType "color" colors the text; zoneType "bars" shows StatusBars
|
|
32
|
+
* zoneType "color" colors the text; zoneType "bars" shows StatusBars;
|
|
33
|
+
* zoneType "dot" shows a HealthDot dot after the value while keeping text default color.
|
|
32
34
|
*
|
|
33
35
|
* @example
|
|
34
36
|
* ```tsx
|
|
35
37
|
* <HealthFactor value={15000} debt={1000000n} />
|
|
38
|
+
* <HealthFactor value={15000} debt={1000000n} zoneType="dot" zone="good" />
|
|
36
39
|
* <HealthFactor value={12000} debt={1000000n} zoneType="bars" zone="medium" />
|
|
37
40
|
* <HealthFactor value={15000} debt={0n} /> // "N/A"
|
|
38
41
|
* ```
|