@gearbox-protocol/ui-kit 4.0.0-next.52 → 4.0.0-next.53
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/esm/components/graph/formatters.js +39 -39
- 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,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 +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
|
-
|