@gearbox-protocol/permissionless-ui 1.24.2 → 1.26.0

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,126 +1,147 @@
1
- import { DateTime as d } from "luxon";
2
- import { isBelowDisplayThreshold as h, FORMAT_CONSTANTS as I, toSignificantDigits as x, formatNumberWithSuffix as T } from "../../utils/format-number.js";
3
- const { MIN_DISPLAY_THRESHOLD: c, MAX_EXPONENTIAL_THRESHOLD: L } = I, H = (t, e, r = "full") => {
4
- if (h(t))
5
- return e ? `<${c}${e}` : `<${c}`;
1
+ import { DateTime as D } from "luxon";
2
+ import { isBelowDisplayThreshold as L, FORMAT_CONSTANTS as G, toSignificantDigits as I, formatNumberWithSuffix as R } from "../../utils/format-number.js";
3
+ const { MIN_DISPLAY_THRESHOLD: f, MAX_EXPONENTIAL_THRESHOLD: p } = G, C = (t, e, r = "full") => {
4
+ if (L(t))
5
+ return e ? `<${f}${e}` : `<${f}`;
6
6
  if (t === 0)
7
7
  return e ? `0${e}` : "0";
8
- const n = T(t, {
9
- maxExponentialThreshold: L,
8
+ const a = R(t, {
9
+ maxExponentialThreshold: p,
10
10
  minimumFractionDigits: 0,
11
11
  maximumFractionDigits: r === "short" ? 1 : 0,
12
12
  format: r,
13
13
  adaptiveDecimals: r === "short"
14
14
  });
15
- return e ? `${n}${e}` : n;
16
- }, R = 2, p = (t, e) => {
17
- if (h(t))
18
- return e ? `<${c}${e}` : `<${c}`;
15
+ return e ? `${a}${e}` : a;
16
+ }, X = 2, H = (t, e) => {
17
+ if (L(t))
18
+ return e ? `<${f}${e}` : `<${f}`;
19
19
  if (t === 0)
20
20
  return e ? `0${e}` : "0";
21
- const r = x(t, R);
21
+ const r = I(t, X);
22
22
  return e ? `${r}${e}` : r;
23
- }, _ = 4, O = (t) => {
24
- if (h(t))
25
- return `<${c}`;
23
+ }, P = 4, b = (t) => {
24
+ if (L(t))
25
+ return `<${f}`;
26
26
  if (t === 0)
27
27
  return "0";
28
28
  const e = Math.round(t), r = Math.abs(t - e);
29
- return r > 0 && r < 0.01 ? t.toFixed(12).replace(/0+$/, "").replace(/\.$/, "") : x(t, _);
30
- }, G = (t, e) => {
31
- if (h(t))
32
- return e ? `<${c} ${e}` : `<${c}`;
29
+ return r > 0 && r < 0.01 ? t.toFixed(12).replace(/0+$/, "").replace(/\.$/, "") : I(t, P);
30
+ }, Y = (t, e) => {
31
+ if (L(t))
32
+ return e ? `<${f} ${e}` : `<${f}`;
33
33
  if (t === 0)
34
34
  return e ? `0 ${e}` : "0";
35
- const r = Number.isInteger(t), n = Math.abs(t), s = r && n >= 1e3, S = Math.round(t), g = Math.abs(t - S);
36
- if (g > 0 && g < 0.01 && !s) {
37
- const M = t.toFixed(12).replace(/0+$/, "").replace(/\.$/, "");
38
- return e ? `${M} ${e}` : M;
35
+ const r = Number.isInteger(t), a = Math.abs(t), s = r && a >= 1e3, u = Math.round(t), d = Math.abs(t - u);
36
+ if (d > 0 && d < 0.01 && !s) {
37
+ const h = t.toFixed(12).replace(/0+$/, "").replace(/\.$/, "");
38
+ return e ? `${h} ${e}` : h;
39
39
  }
40
- const F = T(t, {
41
- maxExponentialThreshold: L,
40
+ const $ = R(t, {
41
+ maxExponentialThreshold: p,
42
42
  minimumFractionDigits: r ? 0 : 2,
43
43
  maximumFractionDigits: s ? 1 : r ? 0 : 2,
44
44
  format: s ? "short" : "full",
45
45
  adaptiveDecimals: s
46
46
  });
47
- return e ? `${F} ${e}` : F;
48
- }, D = {
49
- "%": p,
50
- $: H,
51
- token: G,
52
- none: O
53
- }, k = (t) => D[t] || D.token;
54
- function w(t, e, r = 4) {
47
+ return e ? `${$} ${e}` : $;
48
+ }, N = {
49
+ "%": H,
50
+ $: C,
51
+ token: Y,
52
+ none: b
53
+ }, q = (t) => N[t] || N.token;
54
+ function J(t, e, r = 4) {
55
55
  if (t === 0)
56
56
  return e ? `0 ${e}` : "0";
57
- const n = t.toLocaleString("en-US", {
57
+ const a = t.toLocaleString("en-US", {
58
58
  minimumFractionDigits: 0,
59
59
  maximumFractionDigits: r
60
60
  });
61
- return e ? `${n} ${e}` : n;
61
+ return e ? `${a} ${e}` : a;
62
62
  }
63
- function z(t, e) {
64
- let r = t.length > 0 ? Math.min(...t) : 0, n = t.length > 0 ? Math.max(...t) : 0, s = [];
65
- const S = () => {
66
- const o = n - r, a = (r + n) / 2;
63
+ function Q(t, e, r) {
64
+ const a = r?.yScaleMin;
65
+ let s = t.length > 0 ? Math.min(...t) : 0, u = t.length > 0 ? Math.max(...t) : 0, d = !1, F = [];
66
+ const $ = () => {
67
+ const n = u - s, o = (s + u) / 2;
67
68
  let i = 1, m = "";
68
- a >= 1e9 ? (i = 1e9, m = "B") : a >= 1e6 ? (i = 1e6, m = "M") : a >= 1e3 && (i = 1e3, m = "K");
69
- const f = o / 10 / i;
70
- let u = 1;
71
- if (f > 0) {
72
- const A = Math.floor(Math.log10(f));
73
- u = Math.max(1, -A), u = Math.min(u, 4);
69
+ o >= 1e9 ? (i = 1e9, m = "B") : o >= 1e6 ? (i = 1e6, m = "M") : o >= 1e3 && (i = 1e3, m = "K");
70
+ const M = n / 10 / i;
71
+ let S = 1;
72
+ if (M > 0) {
73
+ const x = Math.floor(Math.log10(M));
74
+ S = Math.max(1, -x), S = Math.min(S, 4);
74
75
  }
75
- return { scale: i, suffix: m, decimals: u };
76
- }, g = (o, a, i) => a > 1 ? `${(o / a).toLocaleString("en-US", {
77
- minimumFractionDigits: 0,
78
- maximumFractionDigits: 4,
79
- useGrouping: !1
80
- })}${i}` : o.toLocaleString("en-US", {
81
- minimumFractionDigits: 0,
82
- maximumFractionDigits: 4,
83
- useGrouping: !1
84
- });
85
- return { formatter: (o) => {
86
- if (o === 0) return "0";
87
- const { scale: a, suffix: i, decimals: m } = S(), $ = Math.abs(o) * 1e-10 || 1e-10;
88
- return s.some((f) => Math.abs(f - o) < $) ? g(o, a, i) : a > 1 ? `${(o / a).toLocaleString("en-US", {
76
+ return { scale: i, suffix: m, decimals: S };
77
+ }, h = (n, o, i) => {
78
+ const m = o > 1 ? n / o : n, g = Math.abs(m) >= 1 ? 1 : 4;
79
+ return o > 1 ? `${(n / o).toLocaleString("en-US", {
80
+ minimumFractionDigits: 0,
81
+ maximumFractionDigits: g,
82
+ useGrouping: !1
83
+ })}${i}` : n.toLocaleString("en-US", {
84
+ minimumFractionDigits: 0,
85
+ maximumFractionDigits: g,
86
+ useGrouping: !1
87
+ });
88
+ }, O = 0.12, U = 0.02;
89
+ return { formatter: (n) => {
90
+ if (a !== void 0 && n < a) return "";
91
+ if (n === 0)
92
+ return d ? "" : (d = !0, "0");
93
+ n > 0 && (d = !1);
94
+ const { scale: o, suffix: i, decimals: m } = $(), g = u - s, l = g > 0 ? F.filter(
95
+ (c) => Math.abs(c) >= g * U
96
+ ) : F, M = Math.abs(n) * 1e-10 || 1e-10;
97
+ if (l.some(
98
+ (c) => Math.abs(c - n) < M
99
+ ))
100
+ return h(n, o, i);
101
+ if (l.length > 0) {
102
+ const c = l.reduce(
103
+ (E, A) => Math.abs(A - n) < Math.abs(E - n) ? A : E
104
+ );
105
+ if (Math.abs(n - c) / (Math.abs(c) || 1e-10) < O)
106
+ return h(c, o, i);
107
+ }
108
+ const x = o > 1 ? n / o : n, T = Math.abs(x) >= 1 ? Math.min(1, m) : m;
109
+ return o > 1 ? `${(n / o).toLocaleString("en-US", {
89
110
  minimumFractionDigits: 0,
90
- maximumFractionDigits: m,
111
+ maximumFractionDigits: T,
91
112
  useGrouping: !1
92
- })}${i}` : o.toLocaleString("en-US", {
113
+ })}${i}` : n.toLocaleString("en-US", {
93
114
  minimumFractionDigits: 0,
94
- maximumFractionDigits: m,
115
+ maximumFractionDigits: T,
95
116
  useGrouping: !1
96
117
  });
97
- }, updateVisibleRange: (o) => {
98
- o.length > 0 && (r = Math.min(...o), n = Math.max(...o));
99
- }, updateLastValues: (o) => {
100
- s = [...o];
118
+ }, updateVisibleRange: (n) => {
119
+ n.length > 0 && (s = Math.min(...n), u = Math.max(...n));
120
+ }, updateLastValues: (n) => {
121
+ F = [...n];
101
122
  } };
102
123
  }
103
- const U = (t) => d.fromSeconds(Number(t)).toFormat("dd/LL/yyyy HH:mm"), X = (t) => d.fromSeconds(Number(t)).toFormat("HH:mm"), C = () => {
124
+ const k = (t) => D.fromSeconds(Number(t)).toFormat("dd/LL/yyyy HH:mm"), w = (t) => D.fromSeconds(Number(t)).toFormat("HH:mm"), z = () => {
104
125
  let t = null;
105
126
  return (e) => {
106
- const r = d.fromSeconds(Number(e)), n = r.toFormat("yyyy-MM-dd");
107
- return n !== t ? (t = n, r.toFormat("dd MMM")) : r.toFormat("HH:mm");
127
+ const r = D.fromSeconds(Number(e)), a = r.toFormat("yyyy-MM-dd");
128
+ return a !== t ? (t = a, r.toFormat("dd MMM")) : r.toFormat("HH:mm");
108
129
  };
109
- }, P = (t, e) => p(Number(t), e), l = {
110
- time: U,
111
- "%": P
112
- }, B = (t, e) => {
130
+ }, B = (t, e) => H(Number(t), e), _ = {
131
+ time: k,
132
+ "%": B
133
+ }, v = (t, e) => {
113
134
  if (t === "time" && e && e.length > 0) {
114
- const r = d.fromSeconds(Number(e[0].time)), n = d.fromSeconds(
135
+ const r = D.fromSeconds(Number(e[0].time)), a = D.fromSeconds(
115
136
  Number(e[e.length - 1].time)
116
137
  );
117
- return r.hasSame(n, "day") ? X : C();
138
+ return r.hasSame(a, "day") ? w : z();
118
139
  }
119
- return l[t] || l.time;
140
+ return _[t] || _.time;
120
141
  };
121
142
  export {
122
- z as createAdaptiveYAxisFormatter,
123
- w as formatExactValue,
124
- B as getXFormatter,
125
- k as getYFormatter
143
+ Q as createAdaptiveYAxisFormatter,
144
+ J as formatExactValue,
145
+ v as getXFormatter,
146
+ q as getYFormatter
126
147
  };
@@ -1,10 +1,10 @@
1
- import { jsxs as c, jsx as e } from "react/jsx-runtime";
2
- import { cva as W } from "class-variance-authority";
3
- import * as G from "react";
4
- import { useMemo as z, useRef as N, useState as L, useEffect as H } from "react";
5
- import { cn as k } from "../../utils/cn.js";
6
- import { Graph as S } from "./graph.js";
7
- const A = W(
1
+ import { jsxs as m, jsx as e } from "react/jsx-runtime";
2
+ import { cva as A } from "class-variance-authority";
3
+ import * as B from "react";
4
+ import { useMemo as D, useRef as N, useState as M, useEffect as E } from "react";
5
+ import { cn as j } from "../../utils/cn.js";
6
+ import { Graph as I } from "./graph.js";
7
+ const O = A(
8
8
  "relative w-full overflow-hidden rounded-lg border-border border bg-card text-card-foreground",
9
9
  {
10
10
  variants: {
@@ -34,45 +34,45 @@ const A = W(
34
34
  padding: "default"
35
35
  }
36
36
  }
37
- ), y = G.forwardRef(
37
+ ), R = B.forwardRef(
38
38
  ({
39
- className: s,
40
- variant: r,
41
- size: i,
39
+ className: n,
40
+ variant: t,
41
+ size: l,
42
42
  padding: o,
43
43
  title: a,
44
- description: l,
45
- toolbar: t,
46
- loading: d = !1,
47
- emptyMessage: m,
48
- error: n,
49
- children: u,
50
- ...p
51
- }, v) => {
52
- const x = a || l || t;
53
- return /* @__PURE__ */ c(
44
+ description: r,
45
+ toolbar: s,
46
+ loading: i = !1,
47
+ emptyMessage: d,
48
+ error: c,
49
+ children: f,
50
+ ...x
51
+ }, p) => {
52
+ const u = a || r || s;
53
+ return /* @__PURE__ */ m(
54
54
  "div",
55
55
  {
56
- ref: v,
57
- className: k(
56
+ ref: p,
57
+ className: j(
58
58
  "flex flex-col",
59
- A({ variant: r, size: i, padding: o, className: s })
59
+ O({ variant: t, size: l, padding: o, className: n })
60
60
  ),
61
- ...p,
61
+ ...x,
62
62
  children: [
63
- x && /* @__PURE__ */ c("div", { className: "mb-4 flex items-start justify-between gap-4 shrink-0", children: [
64
- (a || l) && /* @__PURE__ */ c("div", { className: "flex-1", children: [
63
+ u && /* @__PURE__ */ m("div", { className: "mb-4 flex items-start justify-between gap-4 shrink-0", children: [
64
+ (a || r) && /* @__PURE__ */ m("div", { className: "flex-1", children: [
65
65
  a && /* @__PURE__ */ e("h3", { className: "text-base sm:text-lg font-semibold leading-none tracking-tight", children: a }),
66
- l && /* @__PURE__ */ e("p", { className: "mt-1 text-xs sm:text-sm text-muted-foreground", children: l })
66
+ r && /* @__PURE__ */ e("p", { className: "mt-1 text-xs sm:text-sm text-muted-foreground", children: r })
67
67
  ] }),
68
- t && /* @__PURE__ */ e("div", { className: "shrink-0 w-full", children: t })
68
+ s && /* @__PURE__ */ e("div", { className: "shrink-0 w-full", children: s })
69
69
  ] }),
70
- /* @__PURE__ */ c("div", { className: "relative flex-1 w-full min-h-0", children: [
71
- d && /* @__PURE__ */ e("div", { className: "absolute inset-0 z-10 flex items-center justify-center opacity-0 animate-delayed-fade-in", children: /* @__PURE__ */ c("div", { className: "flex flex-col items-center gap-2", children: [
70
+ /* @__PURE__ */ m("div", { className: "relative flex-1 w-full min-h-0", children: [
71
+ i && /* @__PURE__ */ e("div", { className: "absolute inset-0 z-10 flex items-center justify-center opacity-0 animate-delayed-fade-in", children: /* @__PURE__ */ m("div", { className: "flex flex-col items-center gap-2", children: [
72
72
  /* @__PURE__ */ e("div", { className: "h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent" }),
73
73
  /* @__PURE__ */ e("span", { className: "text-xs sm:text-sm text-muted-foreground", children: "Loading..." })
74
74
  ] }) }),
75
- n && /* @__PURE__ */ e("div", { className: "flex h-full items-center justify-center", children: /* @__PURE__ */ c("div", { className: "flex flex-col items-center gap-2 text-destructive", children: [
75
+ c && /* @__PURE__ */ e("div", { className: "flex h-full items-center justify-center", children: /* @__PURE__ */ m("div", { className: "flex flex-col items-center gap-2 text-destructive", children: [
76
76
  /* @__PURE__ */ e(
77
77
  "svg",
78
78
  {
@@ -92,9 +92,9 @@ const A = W(
92
92
  )
93
93
  }
94
94
  ),
95
- /* @__PURE__ */ e("span", { className: "text-xs sm:text-sm font-medium", children: n })
95
+ /* @__PURE__ */ e("span", { className: "text-xs sm:text-sm font-medium", children: c })
96
96
  ] }) }),
97
- !n && !u && m && /* @__PURE__ */ e("div", { className: "flex h-full items-center justify-center", children: /* @__PURE__ */ c("div", { className: "flex flex-col items-center gap-2 text-muted-foreground", children: [
97
+ !c && !f && d && /* @__PURE__ */ e("div", { className: "flex h-full items-center justify-center", children: /* @__PURE__ */ m("div", { className: "flex flex-col items-center gap-2 text-muted-foreground", children: [
98
98
  /* @__PURE__ */ e(
99
99
  "svg",
100
100
  {
@@ -114,16 +114,16 @@ const A = W(
114
114
  )
115
115
  }
116
116
  ),
117
- /* @__PURE__ */ e("span", { className: "text-xs sm:text-sm", children: m })
117
+ /* @__PURE__ */ e("span", { className: "text-xs sm:text-sm", children: d })
118
118
  ] }) }),
119
119
  /* @__PURE__ */ e(
120
120
  "div",
121
121
  {
122
- className: k(
122
+ className: j(
123
123
  "w-full h-full transition-[filter] duration-300 delay-300",
124
- d && "blur-sm pointer-events-none"
124
+ i && "blur-sm pointer-events-none"
125
125
  ),
126
- children: !n && u
126
+ children: !c && f
127
127
  }
128
128
  )
129
129
  ] })
@@ -132,79 +132,96 @@ const A = W(
132
132
  );
133
133
  }
134
134
  );
135
- y.displayName = "GraphView";
136
- function I({
137
- series: s,
138
- data: r,
139
- graphId: i,
140
- onUnselectSeries: o,
141
- loading: a,
142
- title: l,
143
- description: t,
144
- toolbar: d,
145
- emptyMessage: m = "No data available",
146
- error: n,
147
- containerClassName: u,
148
- variant: p,
149
- size: v,
150
- padding: x,
135
+ R.displayName = "GraphView";
136
+ function Q({
137
+ series: n,
138
+ data: t,
139
+ lineColor: l,
140
+ color: o,
141
+ topColor: a,
142
+ bottomColor: r,
143
+ graphId: s,
144
+ onUnselectSeries: i,
145
+ loading: d,
146
+ title: c,
147
+ description: f,
148
+ toolbar: x,
149
+ emptyMessage: p = "No data available",
150
+ error: u,
151
+ containerClassName: V,
152
+ variant: W,
153
+ size: G,
154
+ padding: z,
151
155
  yMeasureUnit: g,
152
- ...V
156
+ showCurrentValue: b,
157
+ ...L
153
158
  }) {
154
- const h = z(() => s && s.length > 0 ? s : r && r.length > 0 ? [
155
- {
156
- data: r.map((f) => ({
157
- time: typeof f.time == "number" ? f.time : Number(f.time),
158
- value: f.value
159
- })),
160
- label: "Value",
161
- yMeasureUnit: g
159
+ const h = D(() => {
160
+ if (n && n.length > 0)
161
+ return n;
162
+ if (t && t.length > 0) {
163
+ const y = l ?? o;
164
+ return [
165
+ {
166
+ data: t.map((v) => ({
167
+ time: typeof v.time == "number" ? v.time : Number(v.time),
168
+ value: v.value
169
+ })),
170
+ label: "Value",
171
+ yMeasureUnit: g,
172
+ ...y && { lineColor: y },
173
+ ...a && { topColor: a },
174
+ ...r && { bottomColor: r }
175
+ }
176
+ ];
162
177
  }
163
- ] : [], [s, r, g]), j = !a && h.length === 0, b = N(h);
164
- h.length > 0 && (b.current = h);
165
- const w = a && h.length === 0 ? b.current : h, R = w.length > 0;
178
+ return [];
179
+ }, [n, t, g, l, o, a, r]), H = !d && h.length === 0, w = N(h);
180
+ h.length > 0 && (w.current = h);
181
+ const k = d && h.length === 0 ? w.current : h, S = k.length > 0;
166
182
  return /* @__PURE__ */ e(
167
- y,
183
+ R,
168
184
  {
169
- className: u,
170
- variant: p,
171
- size: v,
172
- padding: x,
173
- title: l,
174
- description: t,
175
- toolbar: d,
176
- loading: a,
177
- error: n,
178
- emptyMessage: j ? m : void 0,
179
- children: R && !n && /* @__PURE__ */ e(
180
- S,
185
+ className: V,
186
+ variant: W,
187
+ size: G,
188
+ padding: z,
189
+ title: c,
190
+ description: f,
191
+ toolbar: x,
192
+ loading: d,
193
+ error: u,
194
+ emptyMessage: H ? p : void 0,
195
+ children: S && !u && /* @__PURE__ */ e(
196
+ I,
181
197
  {
182
- series: w,
198
+ series: k,
183
199
  yMeasureUnit: g,
184
- ...o ? { onUnselectSeries: o } : {},
185
- ...V
200
+ ...i ? { onUnselectSeries: i } : {},
201
+ ...b !== void 0 ? { showCurrentValue: b } : {},
202
+ ...L
186
203
  }
187
204
  )
188
205
  }
189
206
  );
190
207
  }
191
- function O(s = 0) {
192
- const r = N(null), i = N(null), [o, a] = L(null);
193
- return H(() => {
194
- const l = () => {
195
- if (r.current && i.current) {
196
- const m = i.current.clientWidth, n = r.current.clientWidth;
197
- a(m - n - s);
208
+ function T(n = 0) {
209
+ const t = N(null), l = N(null), [o, a] = M(null);
210
+ return E(() => {
211
+ const r = () => {
212
+ if (t.current && l.current) {
213
+ const d = l.current.clientWidth, c = t.current.clientWidth;
214
+ a(d - c - n);
198
215
  }
199
- }, t = i.current, d = t ? new ResizeObserver(l) : null;
200
- return t && d?.observe(t), () => {
201
- t && d?.unobserve(t);
216
+ }, s = l.current, i = s ? new ResizeObserver(r) : null;
217
+ return s && i?.observe(s), () => {
218
+ s && i?.unobserve(s);
202
219
  };
203
- }, [s]), { graphWidth: o, parentRef: i, asideRef: r };
220
+ }, [n]), { graphWidth: o, parentRef: l, asideRef: t };
204
221
  }
205
222
  export {
206
- y as GraphView,
207
- I as GraphViewWithData,
208
- A as graphViewVariants,
209
- O as useGraphAside
223
+ R as GraphView,
224
+ Q as GraphViewWithData,
225
+ O as graphViewVariants,
226
+ T as useGraphAside
210
227
  };