@gearbox-protocol/ui-kit 4.0.0-next.52 → 4.0.0-next.54
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/graph/formatters.cjs +1 -1
- package/dist/cjs/components/rounded-image/rounded-image.cjs +1 -1
- package/dist/esm/components/graph/formatters.js +39 -39
- package/dist/esm/components/rounded-image/rounded-image.js +45 -41
- package/dist/types/types/index.d.ts +0 -1
- package/dist/types/utils/ranges.spec.d.ts +0 -1
- package/package.json +1 -1
- package/dist/cjs/types/filter.cjs +0 -1
- package/dist/esm/types/filter.js +0 -1
- package/dist/types/types/filter.d.ts +0 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const F=require("lightweight-charts"),T=require("luxon"),D=require("../../utils/format-number.cjs"),{MIN_DISPLAY_THRESHOLD:$}=D.FORMAT_CONSTANTS,E=2,L=(t,e)=>{if(D.isBelowDisplayThreshold(t))return e?`<${$}${e}`:`<${$}`;if(t===0)return e?`0${e}`:"0";const s=D.toSignificantDigits(t,E);return e?`${s}${e}`:s};function R(t,e,s=4){if(t===0)return e?`0 ${e}`:"0";const n=e&&Math.abs(t)>=1e3?0:s,f=t.toLocaleString("en-US",{minimumFractionDigits:0,maximumFractionDigits:n});return e?`${f} ${e}`:f}function h(t,e){return!t||e==="none"||e==="token"?t:e==="$"?`$${t}`:e==="%"?`${t}%`:`${t} ${e}`}function A(t){return t.includes("/")}function k(t){return A(t)?"none":t}function X(t,e,s){const n=s?.yScaleMin;let f=t.length>0?Math.min(...t):0,c=t.length>0?Math.max(...t):0;const o=()=>{const r=(f+c)/2;let a=1,i="";return r>=1e9?(a=1e9,i="B"):r>=1e6?(a=1e6,i="M"):r>=1e3&&(a=1e3,i="K"),{scale:a,suffix:i}},u=8;let S=0;const g=(r,a,i,d)=>{const m=(a>1?r/a:r).toLocaleString("en-US",{minimumFractionDigits:0,maximumFractionDigits:d,useGrouping:!1});return a>1?`${m}${i}`:m},U=(r,a,i)=>{for(let d=0;d<=u;d++){const M=new Set;let m=!0;for(const l of r){const y=g(l,a,i,d);if(M.has(y)){m=!1;break}M.add(y)}if(m)return d}return u},w=r=>{if(n!==void 0&&r<n)return"";if(r===0)return h("0",k(e));const{scale:a,suffix:i}=o();return h(g(r,a,i,S),k(e))};return{formatter:r=>w(r),tickmarksFormatter:r=>{const{scale:a,suffix:i}=o(),d=r.filter(m=>m!==0&&!(n!==void 0&&m<n));S=U(d,a,i);const M=new Set;return r.map(m=>{if(n!==void 0&&m<n)return"";const l=m===0?"0":g(m,a,i,S);return!l||M.has(l)?"":(M.add(l),h(l,k(e)))})},updateVisibleRange:r=>{r.length>0&&(f=Math.min(...r),c=Math.max(...r))}}}const N=t=>T.DateTime.fromSeconds(Number(t)).toFormat("dd/LL/yyyy HH:mm"),_=t=>T.DateTime.fromSeconds(Number(t)).toFormat("HH:mm"),P=(t,e)=>L(Number(t),e),x={time:N,"%":P};function v(t){const e=new Map;return(s,n,f)=>{const c=T.DateTime.fromSeconds(Number(s));let o;if(t===0)o=c.toFormat("HH:mm");else switch(n){case F.TickMarkType.Year:o=c.toFormat("yyyy");break;case F.TickMarkType.Month:case F.TickMarkType.DayOfMonth:o=t>365?c.toFormat("dd MMM yyyy"):c.toFormat("dd MMM");break;case F.TickMarkType.Time:case F.TickMarkType.TimeWithSeconds:o=c.toFormat("HH:mm");break;default:o=c.toFormat("dd MMM")}let u=e.get(n);return u||(u=new Set,e.set(n,u)),u.has(o)?" ":(u.add(o),o)}}const H=(t,e)=>{if(t==="time"&&e&&e.length>0){const n=T.DateTime.fromSeconds(Number(e[0].time)),f=T.DateTime.fromSeconds(Number(e[e.length-1].time)),c=n.hasSame(f,"day"),o=c?0:Math.ceil(f.diff(n,"days").days);return{timeFormatter:c?_:N,tickMarkFormatter:v(o)}}const s=x[t]||x.time;return{timeFormatter:s,tickMarkFormatter:n=>s(n,t)}},O=(t,e)=>H(t,e).timeFormatter;exports.createAdaptiveYAxisFormatter=X;exports.formatExactValue=R;exports.getXFormatter=O;exports.getXFormatters=H;exports.isRatioUnit=A;exports.withYAxisUnit=h;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const I=require("react/jsx-runtime"),c=require("react");require("@gearbox-protocol/sdk/onchain");const _=require("../../utils/cn.cjs"),L=require("../../utils/static.cjs");require("luxon");require("../../utils/z-index.cjs");function S(e){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(r,n,o.get?o:{enumerable:!0,get:()=>e[n]})}}return r.default=e,Object.freeze(r)}const T=S(c),g=L.getStatic("/tokens/default.svg"),m=new Map;function f(e){return m.get(e)?g:e}const b=T.forwardRef(({className:e,size:r,rounded:n=!0,style:o,src:s,defaultIcon:p=g,fit:y="cover",...R},a)=>{const[j,l]=c.useState(void 0),[h,u]=c.useState(!1),i=c.useRef(!1),d=c.useRef(null),v=t=>{d.current=t,typeof a=="function"?a(t):a&&(a.current=t),t?.complete&&t.naturalWidth>0&&u(!0)};c.useEffect(()=>{f(s),l(void 0),i.current=!1;const t=d.current;u(!!t?.complete&&t.naturalWidth>0)},[s]);const q=t=>{i.current||(i.current=!0,m.set(t.currentTarget.src,!0),l(p))},O=()=>{u(!0)};return I.jsx("img",{ref:v,src:j||f(s),alt:"",className:_.cn(y==="cover"?"object-cover":"object-contain object-center",n&&"rounded-full",!h&&"bg-gray-90 dark:bg-gray-110 rounded-full",e),style:{width:r,height:r,...o},loading:"lazy",decoding:"async",onError:q,onLoad:O,...R})});b.displayName="RoundedImage";exports.RoundedImage=b;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { TickMarkType as
|
|
2
|
-
import { DateTime as
|
|
3
|
-
import { isBelowDisplayThreshold as H, FORMAT_CONSTANTS as
|
|
4
|
-
const { MIN_DISPLAY_THRESHOLD: k
|
|
1
|
+
import { TickMarkType as F } from "lightweight-charts";
|
|
2
|
+
import { DateTime as S } from "luxon";
|
|
3
|
+
import { isBelowDisplayThreshold as H, FORMAT_CONSTANTS as L, toSignificantDigits as E } from "../../utils/format-number.js";
|
|
4
|
+
const { MIN_DISPLAY_THRESHOLD: k } = L, R = 2, U = (t, e) => {
|
|
5
5
|
if (H(t))
|
|
6
6
|
return e ? `<${k}${e}` : `<${k}`;
|
|
7
7
|
if (t === 0)
|
|
8
8
|
return e ? `0${e}` : "0";
|
|
9
|
-
const s =
|
|
9
|
+
const s = E(t, R);
|
|
10
10
|
return e ? `${s}${e}` : s;
|
|
11
11
|
};
|
|
12
|
-
function
|
|
12
|
+
function B(t, e, s = 4) {
|
|
13
13
|
if (t === 0)
|
|
14
14
|
return e ? `0 ${e}` : "0";
|
|
15
15
|
const n = e && Math.abs(t) >= 1e3 ? 0 : s, f = t.toLocaleString("en-US", {
|
|
@@ -21,13 +21,13 @@ function G(t, e, s = 4) {
|
|
|
21
21
|
function D(t, e) {
|
|
22
22
|
return !t || e === "none" || e === "token" ? t : e === "$" ? `$${t}` : e === "%" ? `${t}%` : `${t} ${e}`;
|
|
23
23
|
}
|
|
24
|
-
function
|
|
24
|
+
function _(t) {
|
|
25
25
|
return t.includes("/");
|
|
26
26
|
}
|
|
27
|
-
function
|
|
28
|
-
return
|
|
27
|
+
function $(t) {
|
|
28
|
+
return _(t) ? "none" : t;
|
|
29
29
|
}
|
|
30
|
-
function
|
|
30
|
+
function G(t, e, s) {
|
|
31
31
|
const n = s?.yScaleMin;
|
|
32
32
|
let f = t.length > 0 ? Math.min(...t) : 0, m = t.length > 0 ? Math.max(...t) : 0;
|
|
33
33
|
const a = () => {
|
|
@@ -43,28 +43,28 @@ function W(t, e, s) {
|
|
|
43
43
|
useGrouping: !1
|
|
44
44
|
});
|
|
45
45
|
return o > 1 ? `${c}${i}` : c;
|
|
46
|
-
},
|
|
46
|
+
}, N = (r, o, i) => {
|
|
47
47
|
for (let d = 0; d <= u; d++) {
|
|
48
48
|
const M = /* @__PURE__ */ new Set();
|
|
49
49
|
let c = !0;
|
|
50
|
-
for (const
|
|
51
|
-
const
|
|
52
|
-
if (M.has(
|
|
50
|
+
for (const l of r) {
|
|
51
|
+
const T = g(l, o, i, d);
|
|
52
|
+
if (M.has(T)) {
|
|
53
53
|
c = !1;
|
|
54
54
|
break;
|
|
55
55
|
}
|
|
56
|
-
M.add(
|
|
56
|
+
M.add(T);
|
|
57
57
|
}
|
|
58
58
|
if (c) return d;
|
|
59
59
|
}
|
|
60
60
|
return u;
|
|
61
61
|
}, A = (r) => {
|
|
62
62
|
if (n !== void 0 && r < n) return "";
|
|
63
|
-
if (r === 0) return D("0",
|
|
63
|
+
if (r === 0) return D("0", $(e));
|
|
64
64
|
const { scale: o, suffix: i } = a();
|
|
65
65
|
return D(
|
|
66
66
|
g(r, o, i, h),
|
|
67
|
-
|
|
67
|
+
$(e)
|
|
68
68
|
);
|
|
69
69
|
};
|
|
70
70
|
return {
|
|
@@ -73,12 +73,12 @@ function W(t, e, s) {
|
|
|
73
73
|
const { scale: o, suffix: i } = a(), d = r.filter(
|
|
74
74
|
(c) => c !== 0 && !(n !== void 0 && c < n)
|
|
75
75
|
);
|
|
76
|
-
h =
|
|
76
|
+
h = N(d, o, i);
|
|
77
77
|
const M = /* @__PURE__ */ new Set();
|
|
78
78
|
return r.map((c) => {
|
|
79
79
|
if (n !== void 0 && c < n) return "";
|
|
80
|
-
const
|
|
81
|
-
return !
|
|
80
|
+
const l = c === 0 ? "0" : g(c, o, i, h);
|
|
81
|
+
return !l || M.has(l) ? "" : (M.add(l), D(l, $(e)));
|
|
82
82
|
});
|
|
83
83
|
},
|
|
84
84
|
updateVisibleRange: (r) => {
|
|
@@ -86,31 +86,31 @@ function W(t, e, s) {
|
|
|
86
86
|
}
|
|
87
87
|
};
|
|
88
88
|
}
|
|
89
|
-
const
|
|
90
|
-
time:
|
|
89
|
+
const y = (t) => S.fromSeconds(Number(t)).toFormat("dd/LL/yyyy HH:mm"), w = (t) => S.fromSeconds(Number(t)).toFormat("HH:mm"), P = (t, e) => U(Number(t), e), x = {
|
|
90
|
+
time: y,
|
|
91
91
|
"%": P
|
|
92
92
|
};
|
|
93
|
-
function
|
|
93
|
+
function X(t) {
|
|
94
94
|
const e = /* @__PURE__ */ new Map();
|
|
95
95
|
return (s, n, f) => {
|
|
96
|
-
const m =
|
|
96
|
+
const m = S.fromSeconds(Number(s));
|
|
97
97
|
let a;
|
|
98
98
|
if (t === 0)
|
|
99
99
|
a = m.toFormat("HH:mm");
|
|
100
100
|
else
|
|
101
101
|
switch (n) {
|
|
102
|
-
case
|
|
102
|
+
case F.Year:
|
|
103
103
|
a = m.toFormat("yyyy");
|
|
104
104
|
break;
|
|
105
105
|
// Month boundaries (1st of a month) are reported as `Month` ticks by
|
|
106
106
|
// lightweight-charts. Render them the same way as regular day ticks so
|
|
107
107
|
// the axis reads uniformly ("01 Jul") instead of a stray "Jul 2026".
|
|
108
|
-
case
|
|
109
|
-
case
|
|
108
|
+
case F.Month:
|
|
109
|
+
case F.DayOfMonth:
|
|
110
110
|
a = t > 365 ? m.toFormat("dd MMM yyyy") : m.toFormat("dd MMM");
|
|
111
111
|
break;
|
|
112
|
-
case
|
|
113
|
-
case
|
|
112
|
+
case F.Time:
|
|
113
|
+
case F.TimeWithSeconds:
|
|
114
114
|
a = m.toFormat("HH:mm");
|
|
115
115
|
break;
|
|
116
116
|
default:
|
|
@@ -120,14 +120,14 @@ function U(t) {
|
|
|
120
120
|
return u || (u = /* @__PURE__ */ new Set(), e.set(n, u)), u.has(a) ? " " : (u.add(a), a);
|
|
121
121
|
};
|
|
122
122
|
}
|
|
123
|
-
const
|
|
123
|
+
const O = (t, e) => {
|
|
124
124
|
if (t === "time" && e && e.length > 0) {
|
|
125
|
-
const n =
|
|
125
|
+
const n = S.fromSeconds(Number(e[0].time)), f = S.fromSeconds(
|
|
126
126
|
Number(e[e.length - 1].time)
|
|
127
127
|
), m = n.hasSame(f, "day"), a = m ? 0 : Math.ceil(f.diff(n, "days").days);
|
|
128
128
|
return {
|
|
129
|
-
timeFormatter: m ?
|
|
130
|
-
tickMarkFormatter:
|
|
129
|
+
timeFormatter: m ? w : y,
|
|
130
|
+
tickMarkFormatter: X(a)
|
|
131
131
|
};
|
|
132
132
|
}
|
|
133
133
|
const s = x[t] || x.time;
|
|
@@ -135,12 +135,12 @@ const w = (t, e) => {
|
|
|
135
135
|
timeFormatter: s,
|
|
136
136
|
tickMarkFormatter: (n) => s(n, t)
|
|
137
137
|
};
|
|
138
|
-
},
|
|
138
|
+
}, W = (t, e) => O(t, e).timeFormatter;
|
|
139
139
|
export {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
140
|
+
G as createAdaptiveYAxisFormatter,
|
|
141
|
+
B as formatExactValue,
|
|
142
|
+
W as getXFormatter,
|
|
143
|
+
O as getXFormatters,
|
|
144
|
+
_ as isRatioUnit,
|
|
145
145
|
D as withYAxisUnit
|
|
146
146
|
};
|
|
@@ -1,65 +1,69 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import * as
|
|
3
|
-
import { useState as
|
|
1
|
+
import { jsx as E } from "react/jsx-runtime";
|
|
2
|
+
import * as k from "react";
|
|
3
|
+
import { useState as d, useRef as l, useEffect as w } from "react";
|
|
4
4
|
import "@gearbox-protocol/sdk/onchain";
|
|
5
|
-
import { cn as
|
|
6
|
-
import { getStatic as
|
|
5
|
+
import { cn as N } from "../../utils/cn.js";
|
|
6
|
+
import { getStatic as T } from "../../utils/static.js";
|
|
7
7
|
import "luxon";
|
|
8
8
|
import "../../utils/z-index.js";
|
|
9
|
-
const
|
|
10
|
-
function
|
|
11
|
-
return
|
|
9
|
+
const u = T("/tokens/default.svg"), m = /* @__PURE__ */ new Map();
|
|
10
|
+
function f(t) {
|
|
11
|
+
return m.get(t) ? u : t;
|
|
12
12
|
}
|
|
13
|
-
const
|
|
13
|
+
const U = k.forwardRef(
|
|
14
14
|
({
|
|
15
|
-
className:
|
|
16
|
-
size:
|
|
17
|
-
rounded:
|
|
18
|
-
style:
|
|
19
|
-
src:
|
|
20
|
-
defaultIcon:
|
|
21
|
-
fit:
|
|
22
|
-
...
|
|
23
|
-
},
|
|
24
|
-
const [
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
15
|
+
className: t,
|
|
16
|
+
size: c,
|
|
17
|
+
rounded: g = !0,
|
|
18
|
+
style: p,
|
|
19
|
+
src: o,
|
|
20
|
+
defaultIcon: h = u,
|
|
21
|
+
fit: R = "cover",
|
|
22
|
+
...y
|
|
23
|
+
}, r) => {
|
|
24
|
+
const [v, s] = d(void 0), [b, n] = d(!1), a = l(!1), i = l(null), I = (e) => {
|
|
25
|
+
i.current = e, typeof r == "function" ? r(e) : r && (r.current = e), e?.complete && e.naturalWidth > 0 && n(!0);
|
|
26
|
+
};
|
|
27
|
+
w(() => {
|
|
28
|
+
f(o), s(void 0), a.current = !1;
|
|
29
|
+
const e = i.current;
|
|
30
|
+
n(!!e?.complete && e.naturalWidth > 0);
|
|
31
|
+
}, [o]);
|
|
32
|
+
const L = (e) => {
|
|
33
|
+
a.current || (a.current = !0, m.set(e.currentTarget.src, !0), s(h));
|
|
34
|
+
}, j = () => {
|
|
31
35
|
n(!0);
|
|
32
36
|
};
|
|
33
37
|
return (
|
|
34
38
|
// biome-ignore lint/performance/noImgElement: Universal component that works outside Next.js
|
|
35
|
-
/* @__PURE__ */
|
|
39
|
+
/* @__PURE__ */ E(
|
|
36
40
|
"img",
|
|
37
41
|
{
|
|
38
|
-
ref:
|
|
39
|
-
src:
|
|
42
|
+
ref: I,
|
|
43
|
+
src: v || f(o),
|
|
40
44
|
alt: "",
|
|
41
|
-
className:
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
!
|
|
45
|
-
|
|
45
|
+
className: N(
|
|
46
|
+
R === "cover" ? "object-cover" : "object-contain object-center",
|
|
47
|
+
g && "rounded-full",
|
|
48
|
+
!b && "bg-gray-90 dark:bg-gray-110 rounded-full",
|
|
49
|
+
t
|
|
46
50
|
),
|
|
47
51
|
style: {
|
|
48
|
-
width:
|
|
49
|
-
height:
|
|
50
|
-
...
|
|
52
|
+
width: c,
|
|
53
|
+
height: c,
|
|
54
|
+
...p
|
|
51
55
|
},
|
|
52
56
|
loading: "lazy",
|
|
53
57
|
decoding: "async",
|
|
54
|
-
onError:
|
|
55
|
-
onLoad:
|
|
56
|
-
...
|
|
58
|
+
onError: L,
|
|
59
|
+
onLoad: j,
|
|
60
|
+
...y
|
|
57
61
|
}
|
|
58
62
|
)
|
|
59
63
|
);
|
|
60
64
|
}
|
|
61
65
|
);
|
|
62
|
-
|
|
66
|
+
U.displayName = "RoundedImage";
|
|
63
67
|
export {
|
|
64
|
-
|
|
68
|
+
U as RoundedImage
|
|
65
69
|
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
package/dist/esm/types/filter.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
|