@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.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const T=require("lightweight-charts"),F=require("luxon"),k=require("../../utils/format-number.cjs"),{MIN_DISPLAY_THRESHOLD:$,MAX_EXPONENTIAL_THRESHOLD:q}=k.FORMAT_CONSTANTS,X=2,_=(t,e)=>{if(k.isBelowDisplayThreshold(t))return e?`<${$}${e}`:`<${$}`;if(t===0)return e?`0${e}`:"0";const s=k.toSignificantDigits(t,X);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 S(t,e){return!t||e==="none"||e==="token"?t:e==="$"?`$${t}`:e==="%"?`${t}%`:`${t} ${e}`}function A(t){return t.includes("/")}function D(t){return A(t)?"none":t}function U(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 h=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},H=(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},L=r=>{if(n!==void 0&&r<n)return"";if(r===0)return S("0",D(e));const{scale:a,suffix:i}=o();return S(g(r,a,i,h),D(e))};return{formatter:r=>L(r),tickmarksFormatter:r=>{const{scale:a,suffix:i}=o(),d=r.filter(m=>m!==0&&!(n!==void 0&&m<n));h=H(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,h);return!l||M.has(l)?"":(M.add(l),S(l,D(e)))})},updateVisibleRange:r=>{r.length>0&&(f=Math.min(...r),c=Math.max(...r))}}}const N=t=>F.DateTime.fromSeconds(Number(t)).toFormat("dd/LL/yyyy HH:mm"),w=t=>F.DateTime.fromSeconds(Number(t)).toFormat("HH:mm"),O=(t,e)=>_(Number(t),e),x={time:N,"%":O};function P(t){const e=new Map;return(s,n,f)=>{const c=F.DateTime.fromSeconds(Number(s));let o;if(t===0)o=c.toFormat("HH:mm");else switch(n){case T.TickMarkType.Year:o=c.toFormat("yyyy");break;case T.TickMarkType.Month:case T.TickMarkType.DayOfMonth:o=t>365?c.toFormat("dd MMM yyyy"):c.toFormat("dd MMM");break;case T.TickMarkType.Time:case T.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 E=(t,e)=>{if(t==="time"&&e&&e.length>0){const n=F.DateTime.fromSeconds(Number(e[0].time)),f=F.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?w:N,tickMarkFormatter:P(o)}}const s=x[t]||x.time;return{timeFormatter:s,tickMarkFormatter:n=>s(n,t)}},v=(t,e)=>E(t,e).timeFormatter;exports.createAdaptiveYAxisFormatter=U;exports.formatExactValue=R;exports.getXFormatter=v;exports.getXFormatters=E;exports.isRatioUnit=A;exports.withYAxisUnit=S;
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 l } from "lightweight-charts";
2
- import { DateTime as F } from "luxon";
3
- import { isBelowDisplayThreshold as H, FORMAT_CONSTANTS as E, toSignificantDigits as L } from "../../utils/format-number.js";
4
- const { MIN_DISPLAY_THRESHOLD: k, MAX_EXPONENTIAL_THRESHOLD: B } = E, _ = 2, R = (t, e) => {
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 = L(t, _);
9
+ const s = E(t, R);
10
10
  return e ? `${s}${e}` : s;
11
11
  };
12
- function G(t, e, s = 4) {
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 X(t) {
24
+ function _(t) {
25
25
  return t.includes("/");
26
26
  }
27
- function T(t) {
28
- return X(t) ? "none" : t;
27
+ function $(t) {
28
+ return _(t) ? "none" : t;
29
29
  }
30
- function W(t, e, s) {
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
- }, y = (r, o, i) => {
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 S of r) {
51
- const $ = g(S, o, i, d);
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", T(e));
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
- T(e)
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 = y(d, o, i);
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 S = c === 0 ? "0" : g(c, o, i, h);
81
- return !S || M.has(S) ? "" : (M.add(S), D(S, T(e)));
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 N = (t) => F.fromSeconds(Number(t)).toFormat("dd/LL/yyyy HH:mm"), O = (t) => F.fromSeconds(Number(t)).toFormat("HH:mm"), P = (t, e) => R(Number(t), e), x = {
90
- time: N,
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 U(t) {
93
+ function X(t) {
94
94
  const e = /* @__PURE__ */ new Map();
95
95
  return (s, n, f) => {
96
- const m = F.fromSeconds(Number(s));
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 l.Year:
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 l.Month:
109
- case l.DayOfMonth:
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 l.Time:
113
- case l.TimeWithSeconds:
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 w = (t, e) => {
123
+ const O = (t, e) => {
124
124
  if (t === "time" && e && e.length > 0) {
125
- const n = F.fromSeconds(Number(e[0].time)), f = F.fromSeconds(
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 ? O : N,
130
- tickMarkFormatter: U(a)
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
- }, p = (t, e) => w(t, e).timeFormatter;
138
+ }, W = (t, e) => O(t, e).timeFormatter;
139
139
  export {
140
- W as createAdaptiveYAxisFormatter,
141
- G as formatExactValue,
142
- p as getXFormatter,
143
- w as getXFormatters,
144
- X as isRatioUnit,
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,3 +1,2 @@
1
- export type * from './filter';
2
1
  export type * from './graph';
3
2
  export type * from './range-item';
@@ -1 +0,0 @@
1
- export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/ui-kit",
3
- "version": "4.0.0-next.52",
3
+ "version": "4.0.0-next.53",
4
4
  "description": "Internal UI components",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1 +0,0 @@
1
- "use strict";
@@ -1 +0,0 @@
1
-
@@ -1,8 +0,0 @@
1
- /**
2
- * Types for filter components
3
- */
4
- export interface RangeNumber {
5
- balance: bigint;
6
- balanceView: string;
7
- }
8
- export type FilterRange = readonly [RangeNumber, RangeNumber];