@gearbox-protocol/ui-kit 3.13.1 → 3.14.0-next.10

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.
Files changed (30) hide show
  1. package/dist/cjs/components/buttons/button/button.cjs +1 -1
  2. package/dist/cjs/components/client-adapters/styled-button/styled-button.cjs +1 -1
  3. package/dist/cjs/components/composites/strategies-table/components/rewards-tooltip/tooltip-content.cjs +1 -1
  4. package/dist/cjs/components/graph/formatters.cjs +1 -1
  5. package/dist/cjs/components/graph/graph.cjs +1 -1
  6. package/dist/cjs/components/layout/main-aside-layout/main-aside-layout.cjs +1 -1
  7. package/dist/cjs/components/smart-number-input/smart-number-input.cjs +1 -1
  8. package/dist/cjs/components/trading-view/trading-view.cjs +1 -1
  9. package/dist/cjs/locale/en.json.cjs +1 -1
  10. package/dist/esm/components/buttons/button/button.js +1 -0
  11. package/dist/esm/components/client-adapters/styled-button/styled-button.js +11 -11
  12. package/dist/esm/components/composites/strategies-table/components/rewards-tooltip/tooltip-content.js +131 -122
  13. package/dist/esm/components/graph/formatters.js +127 -132
  14. package/dist/esm/components/graph/graph.js +339 -293
  15. package/dist/esm/components/health-factor/health-factor.js +3 -3
  16. package/dist/esm/components/layout/main-aside-layout/main-aside-layout.js +104 -21
  17. package/dist/esm/components/smart-number-input/smart-number-input.js +253 -104
  18. package/dist/esm/components/trading-view/trading-view.js +58 -58
  19. package/dist/esm/locale/en.json.js +2 -0
  20. package/dist/globals.css +1 -1
  21. package/dist/types/components/buttons/button/button.d.ts +4 -3
  22. package/dist/types/components/graph/graph.d.ts +8 -1
  23. package/dist/types/components/help-tip/help-tip.d.ts +2 -2
  24. package/dist/types/components/layout/main-aside-layout/main-aside-layout.d.ts +80 -5
  25. package/dist/types/components/smart-number-input/smart-number-input.d.ts +52 -0
  26. package/dist/types/components/tip-card/tip-card.d.ts +1 -1
  27. package/dist/types/components/trading-view/trading-view.d.ts +7 -0
  28. package/dist/types/locale/en.json.d.ts +2 -0
  29. package/package.json +3 -3
  30. package/src/styles/base.css +4 -2
@@ -1,189 +1,184 @@
1
- import { TickMarkType as S } from "lightweight-charts";
2
- import { DateTime as $ } from "luxon";
3
- import { isBelowDisplayThreshold as x, FORMAT_CONSTANTS as U, toSignificantDigits as H, formatNumberWithSuffix as I } from "../../utils/format-number.js";
4
- const { MIN_DISPLAY_THRESHOLD: g, MAX_EXPONENTIAL_THRESHOLD: R } = U, V = (t, e, n = "full") => {
1
+ import { TickMarkType as g } from "lightweight-charts";
2
+ import { DateTime as S } from "luxon";
3
+ import { isBelowDisplayThreshold as x, FORMAT_CONSTANTS as X, toSignificantDigits as k, formatNumberWithSuffix as L } from "../../utils/format-number.js";
4
+ const { MIN_DISPLAY_THRESHOLD: h, MAX_EXPONENTIAL_THRESHOLD: I } = X, P = (t, e, o = "full") => {
5
5
  if (x(t))
6
- return e ? `<${g}${e}` : `<${g}`;
6
+ return e ? `<${h}${e}` : `<${h}`;
7
7
  if (t === 0)
8
8
  return e ? `0${e}` : "0";
9
- const a = I(t, {
10
- maxExponentialThreshold: R,
9
+ const r = L(t, {
10
+ maxExponentialThreshold: I,
11
11
  minimumFractionDigits: 0,
12
- maximumFractionDigits: n === "short" ? 1 : 0,
13
- format: n,
14
- adaptiveDecimals: n === "short"
12
+ maximumFractionDigits: o === "short" ? 1 : 0,
13
+ format: o,
14
+ adaptiveDecimals: o === "short"
15
15
  });
16
- return e ? `${a}${e}` : a;
17
- }, X = 2, O = (t, e) => {
16
+ return e ? `${r}${e}` : r;
17
+ }, U = 2, p = (t, e) => {
18
18
  if (x(t))
19
- return e ? `<${g}${e}` : `<${g}`;
19
+ return e ? `<${h}${e}` : `<${h}`;
20
20
  if (t === 0)
21
21
  return e ? `0${e}` : "0";
22
- const n = H(t, X);
23
- return e ? `${n}${e}` : n;
24
- }, P = 4, C = (t) => {
22
+ const o = k(t, U);
23
+ return e ? `${o}${e}` : o;
24
+ }, C = 4, w = (t) => {
25
25
  if (x(t))
26
- return `<${g}`;
26
+ return `<${h}`;
27
27
  if (t === 0)
28
28
  return "0";
29
- const e = Math.round(t), n = Math.abs(t - e);
30
- return n > 0 && n < 0.01 ? t.toFixed(12).replace(/0+$/, "").replace(/\.$/, "") : H(t, P);
31
- }, w = (t, e) => {
29
+ const e = Math.round(t), o = Math.abs(t - e);
30
+ return o > 0 && o < 0.01 ? t.toFixed(12).replace(/0+$/, "").replace(/\.$/, "") : k(t, C);
31
+ }, G = (t, e) => {
32
32
  if (x(t))
33
- return e ? `<${g} ${e}` : `<${g}`;
33
+ return e ? `<${h} ${e}` : `<${h}`;
34
34
  if (t === 0)
35
35
  return e ? `0 ${e}` : "0";
36
- const n = Number.isInteger(t), a = Math.abs(t), c = n && a >= 1e3, s = Math.round(t), o = Math.abs(t - s);
37
- if (o > 0 && o < 0.01 && !c) {
38
- const D = t.toFixed(12).replace(/0+$/, "").replace(/\.$/, "");
39
- return e ? `${D} ${e}` : D;
36
+ const o = Number.isInteger(t), r = Math.abs(t), s = o && r >= 1e3, i = Math.round(t), a = Math.abs(t - i);
37
+ if (a > 0 && a < 0.01 && !s) {
38
+ const $ = t.toFixed(12).replace(/0+$/, "").replace(/\.$/, "");
39
+ return e ? `${$} ${e}` : $;
40
40
  }
41
- const l = I(t, {
42
- maxExponentialThreshold: R,
43
- minimumFractionDigits: n ? 0 : 2,
44
- maximumFractionDigits: c ? 1 : n ? 0 : 2,
45
- format: c ? "short" : "full",
46
- adaptiveDecimals: c
41
+ const F = L(t, {
42
+ maxExponentialThreshold: I,
43
+ minimumFractionDigits: o ? 0 : 2,
44
+ maximumFractionDigits: s ? 1 : o ? 0 : 2,
45
+ format: s ? "short" : "full",
46
+ adaptiveDecimals: s
47
47
  });
48
- return e ? `${l} ${e}` : l;
48
+ return e ? `${F} ${e}` : F;
49
49
  }, N = {
50
- "%": O,
51
- $: V,
52
- token: w,
53
- none: C
54
- }, tt = (t) => N[t] || N.token;
55
- function et(t, e, n = 4) {
50
+ "%": p,
51
+ $: P,
52
+ token: G,
53
+ none: w
54
+ }, J = (t) => N[t] || N.token;
55
+ function Z(t, e, o = 4) {
56
56
  if (t === 0)
57
57
  return e ? `0 ${e}` : "0";
58
- const a = e && Math.abs(t) >= 1e3 ? 0 : n, c = t.toLocaleString("en-US", {
58
+ const r = e && Math.abs(t) >= 1e3 ? 0 : o, s = t.toLocaleString("en-US", {
59
59
  minimumFractionDigits: 0,
60
- maximumFractionDigits: a
60
+ maximumFractionDigits: r
61
61
  });
62
- return e ? `${c} ${e}` : c;
62
+ return e ? `${s} ${e}` : s;
63
63
  }
64
- function rt(t, e, n) {
65
- const a = n?.yScaleMin;
66
- let c = t.length > 0 ? Math.min(...t) : 0, s = t.length > 0 ? Math.max(...t) : 0, o = [];
64
+ function v(t, e, o) {
65
+ const r = o?.yScaleMin;
66
+ let s = t.length > 0 ? Math.min(...t) : 0, i = t.length > 0 ? Math.max(...t) : 0, a = [];
67
67
  const u = () => {
68
- const r = s - c, i = (c + s) / 2;
69
- let f = 1, m = "";
70
- i >= 1e9 ? (f = 1e9, m = "B") : i >= 1e6 ? (f = 1e6, m = "M") : i >= 1e3 && (f = 1e3, m = "K");
71
- const T = r / 10 / f;
72
- let M = 1;
73
- if (T > 0) {
74
- const L = Math.floor(Math.log10(T));
75
- M = Math.max(1, -L), M = Math.min(M, 4);
76
- }
77
- return { scale: f, suffix: m, decimals: M };
78
- }, l = (r, i, f) => {
79
- const m = i > 1 ? r / i : r, d = Math.abs(m) >= 1 ? 1 : 4;
80
- return i > 1 ? `${(r / i).toLocaleString("en-US", {
81
- minimumFractionDigits: 0,
82
- maximumFractionDigits: d,
83
- useGrouping: !1
84
- })}${f}` : r.toLocaleString("en-US", {
68
+ const n = (s + i) / 2;
69
+ let c = 1, m = "";
70
+ return n >= 1e9 ? (c = 1e9, m = "B") : n >= 1e6 ? (c = 1e6, m = "M") : n >= 1e3 && (c = 1e3, m = "K"), { scale: c, suffix: m };
71
+ }, F = 8, $ = 0.02;
72
+ let A = 0;
73
+ const E = (n, c, m, d) => {
74
+ const M = (c > 1 ? n / c : n).toLocaleString("en-US", {
85
75
  minimumFractionDigits: 0,
86
76
  maximumFractionDigits: d,
87
77
  useGrouping: !1
88
78
  });
89
- }, D = 0.02, k = (r) => {
90
- if (a !== void 0 && r < a) return "";
91
- if (r === 0) return "0";
92
- const { scale: i, suffix: f, decimals: m } = u(), d = s - c, F = d > 0 ? o.filter(
93
- (h) => Math.abs(h) >= d * D
94
- ) : o, M = (d > 0 ? d / 10 : 0) * 0.05, L = Math.abs(r) * 1e-10 || 1e-10;
95
- if (F.some(
96
- (h) => Math.abs(h - r) < L
97
- ))
98
- return l(r, i, f);
99
- if (F.length > 0 && M > 0) {
100
- const h = F.reduce(
101
- (p, A) => Math.abs(A - r) < Math.abs(p - r) ? A : p
102
- );
103
- if (Math.abs(r - h) < M)
104
- return l(h, i, f);
79
+ return c > 1 ? `${M}${m}` : M;
80
+ }, R = (n, c, m) => {
81
+ for (let d = 0; d <= F; d++) {
82
+ const l = /* @__PURE__ */ new Set();
83
+ let M = !0;
84
+ for (const D of n) {
85
+ const f = E(D, c, m, d);
86
+ if (l.has(f)) {
87
+ M = !1;
88
+ break;
89
+ }
90
+ l.add(f);
91
+ }
92
+ if (M) return d;
105
93
  }
106
- const G = i > 1 ? r / i : r, E = Math.abs(G) >= 1 ? Math.min(1, m) : m;
107
- return i > 1 ? `${(r / i).toLocaleString("en-US", {
108
- minimumFractionDigits: 0,
109
- maximumFractionDigits: E,
110
- useGrouping: !1
111
- })}${f}` : r.toLocaleString("en-US", {
112
- minimumFractionDigits: 0,
113
- maximumFractionDigits: E,
114
- useGrouping: !1
115
- });
94
+ return F;
95
+ }, O = (n) => {
96
+ if (r !== void 0 && n < r) return "";
97
+ if (n === 0) return "0";
98
+ const { scale: c, suffix: m } = u();
99
+ return E(n, c, m, A);
116
100
  };
117
101
  return {
118
- formatter: (r) => k(r),
119
- tickmarksFormatter: (r) => {
120
- const i = /* @__PURE__ */ new Set();
121
- return r.map((f) => {
122
- const m = k(f);
123
- return !m || i.has(m) ? "" : (i.add(m), m);
102
+ formatter: (n) => O(n),
103
+ tickmarksFormatter: (n) => {
104
+ const { scale: c, suffix: m } = u(), d = i - s, l = d > 0 ? a.filter(
105
+ (f) => Math.abs(f) >= d * $
106
+ ) : a, M = n.filter(
107
+ (f) => f !== 0 && !(r !== void 0 && f < r)
108
+ );
109
+ A = R(
110
+ [...M, ...l],
111
+ c,
112
+ m
113
+ );
114
+ const D = /* @__PURE__ */ new Set();
115
+ return n.map((f) => {
116
+ if (r !== void 0 && f < r) return "";
117
+ const T = f === 0 ? "0" : E(f, c, m, A);
118
+ return !T || D.has(T) ? "" : (D.add(T), T);
124
119
  });
125
120
  },
126
- updateVisibleRange: (r) => {
127
- r.length > 0 && (c = Math.min(...r), s = Math.max(...r));
121
+ updateVisibleRange: (n) => {
122
+ n.length > 0 && (s = Math.min(...n), i = Math.max(...n));
128
123
  },
129
- updateLastValues: (r) => {
130
- o = [...r];
124
+ updateLastValues: (n) => {
125
+ a = [...n];
131
126
  }
132
127
  };
133
128
  }
134
- const b = (t) => $.fromSeconds(Number(t)).toFormat("dd/LL/yyyy HH:mm"), Y = (t) => $.fromSeconds(Number(t)).toFormat("HH:mm"), y = (t, e) => O(Number(t), e), _ = {
135
- time: b,
136
- "%": y
129
+ const H = (t) => S.fromSeconds(Number(t)).toFormat("dd/LL/yyyy HH:mm"), Y = (t) => S.fromSeconds(Number(t)).toFormat("HH:mm"), b = (t, e) => p(Number(t), e), _ = {
130
+ time: H,
131
+ "%": b
137
132
  };
138
- function W(t) {
133
+ function V(t) {
139
134
  const e = /* @__PURE__ */ new Map();
140
- return (n, a, c) => {
141
- const s = $.fromSeconds(Number(n));
142
- let o;
135
+ return (o, r, s) => {
136
+ const i = S.fromSeconds(Number(o));
137
+ let a;
143
138
  if (t === 0)
144
- o = s.toFormat("HH:mm");
139
+ a = i.toFormat("HH:mm");
145
140
  else
146
- switch (a) {
147
- case S.Year:
148
- o = s.toFormat("yyyy");
141
+ switch (r) {
142
+ case g.Year:
143
+ a = i.toFormat("yyyy");
149
144
  break;
150
- case S.Month:
151
- o = s.toFormat("MMM yy");
145
+ case g.Month:
146
+ a = i.toFormat("MMM yy");
152
147
  break;
153
- case S.DayOfMonth:
154
- o = t > 365 ? s.toFormat("dd MMM yy") : s.toFormat("dd MMM");
148
+ case g.DayOfMonth:
149
+ a = t > 365 ? i.toFormat("dd MMM yy") : i.toFormat("dd MMM");
155
150
  break;
156
- case S.Time:
157
- case S.TimeWithSeconds:
158
- o = s.toFormat("HH:mm");
151
+ case g.Time:
152
+ case g.TimeWithSeconds:
153
+ a = i.toFormat("HH:mm");
159
154
  break;
160
155
  default:
161
- o = s.toFormat("dd MMM");
156
+ a = i.toFormat("dd MMM");
162
157
  }
163
- let u = e.get(a);
164
- return u || (u = /* @__PURE__ */ new Set(), e.set(a, u)), u.has(o) ? " " : (u.add(o), o);
158
+ let u = e.get(r);
159
+ return u || (u = /* @__PURE__ */ new Set(), e.set(r, u)), u.has(a) ? " " : (u.add(a), a);
165
160
  };
166
161
  }
167
- const z = (t, e) => {
162
+ const W = (t, e) => {
168
163
  if (t === "time" && e && e.length > 0) {
169
- const a = $.fromSeconds(Number(e[0].time)), c = $.fromSeconds(
164
+ const r = S.fromSeconds(Number(e[0].time)), s = S.fromSeconds(
170
165
  Number(e[e.length - 1].time)
171
- ), s = a.hasSame(c, "day"), o = s ? 0 : Math.ceil(c.diff(a, "days").days);
166
+ ), i = r.hasSame(s, "day"), a = i ? 0 : Math.ceil(s.diff(r, "days").days);
172
167
  return {
173
- timeFormatter: s ? Y : b,
174
- tickMarkFormatter: W(o)
168
+ timeFormatter: i ? Y : H,
169
+ tickMarkFormatter: V(a)
175
170
  };
176
171
  }
177
- const n = _[t] || _.time;
172
+ const o = _[t] || _.time;
178
173
  return {
179
- timeFormatter: n,
180
- tickMarkFormatter: (a) => n(a, void 0)
174
+ timeFormatter: o,
175
+ tickMarkFormatter: (r) => o(r, void 0)
181
176
  };
182
- }, nt = (t, e) => z(t, e).timeFormatter;
177
+ }, tt = (t, e) => W(t, e).timeFormatter;
183
178
  export {
184
- rt as createAdaptiveYAxisFormatter,
185
- et as formatExactValue,
186
- nt as getXFormatter,
187
- z as getXFormatters,
188
- tt as getYFormatter
179
+ v as createAdaptiveYAxisFormatter,
180
+ Z as formatExactValue,
181
+ tt as getXFormatter,
182
+ W as getXFormatters,
183
+ J as getYFormatter
189
184
  };