@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.
- package/dist/cjs/components/buttons/button/button.cjs +1 -1
- package/dist/cjs/components/client-adapters/styled-button/styled-button.cjs +1 -1
- package/dist/cjs/components/composites/strategies-table/components/rewards-tooltip/tooltip-content.cjs +1 -1
- package/dist/cjs/components/graph/formatters.cjs +1 -1
- package/dist/cjs/components/graph/graph.cjs +1 -1
- package/dist/cjs/components/layout/main-aside-layout/main-aside-layout.cjs +1 -1
- package/dist/cjs/components/smart-number-input/smart-number-input.cjs +1 -1
- package/dist/cjs/components/trading-view/trading-view.cjs +1 -1
- package/dist/cjs/locale/en.json.cjs +1 -1
- package/dist/esm/components/buttons/button/button.js +1 -0
- package/dist/esm/components/client-adapters/styled-button/styled-button.js +11 -11
- package/dist/esm/components/composites/strategies-table/components/rewards-tooltip/tooltip-content.js +131 -122
- package/dist/esm/components/graph/formatters.js +127 -132
- package/dist/esm/components/graph/graph.js +339 -293
- package/dist/esm/components/health-factor/health-factor.js +3 -3
- package/dist/esm/components/layout/main-aside-layout/main-aside-layout.js +104 -21
- package/dist/esm/components/smart-number-input/smart-number-input.js +253 -104
- package/dist/esm/components/trading-view/trading-view.js +58 -58
- package/dist/esm/locale/en.json.js +2 -0
- package/dist/globals.css +1 -1
- package/dist/types/components/buttons/button/button.d.ts +4 -3
- package/dist/types/components/graph/graph.d.ts +8 -1
- package/dist/types/components/help-tip/help-tip.d.ts +2 -2
- package/dist/types/components/layout/main-aside-layout/main-aside-layout.d.ts +80 -5
- package/dist/types/components/smart-number-input/smart-number-input.d.ts +52 -0
- package/dist/types/components/tip-card/tip-card.d.ts +1 -1
- package/dist/types/components/trading-view/trading-view.d.ts +7 -0
- package/dist/types/locale/en.json.d.ts +2 -0
- package/package.json +3 -3
- package/src/styles/base.css +4 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsxs as S, jsx as l } from "react/jsx-runtime";
|
|
2
|
-
import { useMemo as y, useCallback as ne, useRef as
|
|
2
|
+
import { useMemo as y, useCallback as ne, useRef as E } from "react";
|
|
3
3
|
import { toast as ie } from "sonner";
|
|
4
4
|
import { useIsMobile as le } from "../../hooks/use-media-query.js";
|
|
5
5
|
import "@gearbox-protocol/sdk";
|
|
@@ -8,7 +8,7 @@ import "@gearbox-protocol/sdk/common-utils";
|
|
|
8
8
|
import "luxon";
|
|
9
9
|
import "../../utils/z-index.js";
|
|
10
10
|
import { RangeButtons as ce } from "../buttons/range-buttons/range-buttons.js";
|
|
11
|
-
import { DEFAULT_SERIES_COLORS as
|
|
11
|
+
import { DEFAULT_SERIES_COLORS as k, getSeriesColorPalette as ue } from "../graph/graph.js";
|
|
12
12
|
import { GraphViewWithData as me } from "../graph/graph-view.js";
|
|
13
13
|
import { GraphDropdown as fe } from "./graph-dropdown.js";
|
|
14
14
|
const de = ({ size: e = 16 }) => /* @__PURE__ */ S(
|
|
@@ -45,17 +45,17 @@ const de = ({ size: e = 16 }) => /* @__PURE__ */ S(
|
|
|
45
45
|
/* @__PURE__ */ l("path", { d: "M8 3v3a2 2 0 0 1-2 2H3m18 0h-3a2 2 0 0 1-2-2V3m0 18v-3a2 2 0 0 1 2-2h3M3 16h3a2 2 0 0 1 2 2v3" })
|
|
46
46
|
]
|
|
47
47
|
}
|
|
48
|
-
),
|
|
49
|
-
function
|
|
48
|
+
), V = "ui-kit:tradingview-series-colors:";
|
|
49
|
+
function j(e) {
|
|
50
50
|
if (typeof window > "u" || !window.localStorage)
|
|
51
51
|
return /* @__PURE__ */ new Map();
|
|
52
52
|
try {
|
|
53
|
-
const t = window.localStorage.getItem(
|
|
53
|
+
const t = window.localStorage.getItem(V + e);
|
|
54
54
|
if (!t) return /* @__PURE__ */ new Map();
|
|
55
55
|
const c = JSON.parse(t);
|
|
56
56
|
return c == null || typeof c != "object" ? /* @__PURE__ */ new Map() : new Map(
|
|
57
57
|
Object.entries(c).filter(
|
|
58
|
-
([, o]) => typeof o == "number" && o >= 0 && o <
|
|
58
|
+
([, o]) => typeof o == "number" && o >= 0 && o < k.length
|
|
59
59
|
)
|
|
60
60
|
);
|
|
61
61
|
} catch {
|
|
@@ -66,17 +66,17 @@ function we(e, t) {
|
|
|
66
66
|
if (!(typeof window > "u" || !window.localStorage))
|
|
67
67
|
try {
|
|
68
68
|
window.localStorage.setItem(
|
|
69
|
-
|
|
69
|
+
V + e,
|
|
70
70
|
JSON.stringify(Object.fromEntries(t))
|
|
71
71
|
);
|
|
72
72
|
} catch {
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
|
-
function
|
|
75
|
+
function F(e, t) {
|
|
76
76
|
if (t.size === 0) return;
|
|
77
|
-
const c =
|
|
78
|
-
for (const [o,
|
|
79
|
-
c.set(o,
|
|
77
|
+
const c = j(e);
|
|
78
|
+
for (const [o, v] of t)
|
|
79
|
+
c.set(o, v);
|
|
80
80
|
we(e, c);
|
|
81
81
|
}
|
|
82
82
|
function Re({
|
|
@@ -84,18 +84,18 @@ function Re({
|
|
|
84
84
|
yMeasureUnit: t,
|
|
85
85
|
height: c = 306,
|
|
86
86
|
defaultGraph: o,
|
|
87
|
-
onGraphSelected:
|
|
87
|
+
onGraphSelected: v,
|
|
88
88
|
graphs: d,
|
|
89
|
-
isMultipleSelect:
|
|
90
|
-
range:
|
|
91
|
-
rangeList:
|
|
92
|
-
setRange:
|
|
89
|
+
isMultipleSelect: B,
|
|
90
|
+
range: T,
|
|
91
|
+
rangeList: N,
|
|
92
|
+
setRange: D,
|
|
93
93
|
onGraphExpanded: A,
|
|
94
|
-
isGraphExpanded:
|
|
95
|
-
onUnselectSeries:
|
|
96
|
-
graphsWithNoData:
|
|
97
|
-
loadingGraphs:
|
|
98
|
-
noDataMessage:
|
|
94
|
+
isGraphExpanded: W,
|
|
95
|
+
onUnselectSeries: H,
|
|
96
|
+
graphsWithNoData: J,
|
|
97
|
+
loadingGraphs: I,
|
|
98
|
+
noDataMessage: R = "No data available for this graph",
|
|
99
99
|
currentValueDecimals: $,
|
|
100
100
|
containerClassName: X,
|
|
101
101
|
useSharedPriceScale: q,
|
|
@@ -105,51 +105,51 @@ function Re({
|
|
|
105
105
|
seriesColorPersistenceKey: u,
|
|
106
106
|
...U
|
|
107
107
|
}) {
|
|
108
|
-
const
|
|
108
|
+
const b = y(() => Array.isArray(e) ? e : e ? [e] : [], [e]), L = y(() => Array.isArray(e) && e.length > 1, [e]), O = le(), K = ne(
|
|
109
109
|
(w, g) => {
|
|
110
|
-
ie.error(
|
|
110
|
+
ie.error(R);
|
|
111
111
|
},
|
|
112
|
-
[
|
|
112
|
+
[R]
|
|
113
113
|
), P = y(() => {
|
|
114
114
|
if (t)
|
|
115
115
|
return Array.isArray(t) ? t[0] : t;
|
|
116
|
-
}, [t]), G = (!
|
|
117
|
-
/* @__PURE__ */ l("div", { children:
|
|
116
|
+
}, [t]), G = (!O && A || N.length > 0 || v && d && o) && /* @__PURE__ */ S("div", { className: "z-10 w-full flex flex-row flex-wrap sm:flex-nowrap items-center gap-2", children: [
|
|
117
|
+
/* @__PURE__ */ l("div", { children: v && d && o && /* @__PURE__ */ l(
|
|
118
118
|
fe,
|
|
119
119
|
{
|
|
120
|
-
onSelected:
|
|
120
|
+
onSelected: v,
|
|
121
121
|
items: d,
|
|
122
122
|
defaultItem: o,
|
|
123
|
-
multiple:
|
|
124
|
-
graphsWithNoData:
|
|
125
|
-
loadingGraphs:
|
|
123
|
+
multiple: B,
|
|
124
|
+
graphsWithNoData: J,
|
|
125
|
+
loadingGraphs: I,
|
|
126
126
|
onNoDataSelected: K
|
|
127
127
|
}
|
|
128
128
|
) }),
|
|
129
129
|
/* @__PURE__ */ S("div", { className: "flex flex-row flex-nowrap justify-start sm:justify-end items-center flex-1", children: [
|
|
130
|
-
/* @__PURE__ */ l(ce, { range:
|
|
131
|
-
!
|
|
130
|
+
/* @__PURE__ */ l(ce, { range: T, rangeList: N, setRange: D }),
|
|
131
|
+
!O && A && /* @__PURE__ */ l(
|
|
132
132
|
"button",
|
|
133
133
|
{
|
|
134
134
|
type: "button",
|
|
135
135
|
className: "px-2.5 py-1.5 flex min-w-[44px] min-h-[26px] justify-center items-center text-xs leading-[14px] font-medium text-center rounded-md border cursor-pointer transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring bg-muted border-muted text-muted-foreground hover:border-secondary ml-1.5",
|
|
136
136
|
onClick: A,
|
|
137
|
-
children:
|
|
137
|
+
children: W ? /* @__PURE__ */ l(ae, { size: 16 }) : /* @__PURE__ */ l(de, { size: 16 })
|
|
138
138
|
}
|
|
139
139
|
)
|
|
140
140
|
] })
|
|
141
|
-
] }), i =
|
|
142
|
-
if (d && d.length > 0 && !
|
|
143
|
-
|
|
144
|
-
const w = u ?
|
|
141
|
+
] }), i = E(/* @__PURE__ */ new Map()), a = E(0), _ = E(!1);
|
|
142
|
+
if (d && d.length > 0 && !_.current) {
|
|
143
|
+
_.current = !0;
|
|
144
|
+
const w = u ? j(u) : /* @__PURE__ */ new Map(), g = String(d[0].value);
|
|
145
145
|
i.current.set(g, 0), a.current = 1;
|
|
146
146
|
for (let r = 1; r < d.length; r++) {
|
|
147
147
|
const m = String(d[r].value);
|
|
148
148
|
if (i.current.has(m)) continue;
|
|
149
|
-
const
|
|
150
|
-
i.current.set(m,
|
|
149
|
+
const p = w.get(m) ?? r;
|
|
150
|
+
i.current.set(m, p), a.current = Math.max(a.current, p + 1);
|
|
151
151
|
}
|
|
152
|
-
u &&
|
|
152
|
+
u && F(
|
|
153
153
|
u,
|
|
154
154
|
i.current
|
|
155
155
|
);
|
|
@@ -157,42 +157,42 @@ function Re({
|
|
|
157
157
|
const ee = y(() => {
|
|
158
158
|
const w = Array.isArray(t) ? t : void 0;
|
|
159
159
|
if (u) {
|
|
160
|
-
const r =
|
|
160
|
+
const r = j(u);
|
|
161
161
|
for (const [m, x] of r)
|
|
162
162
|
i.current.has(m) || (i.current.set(m, x), a.current = Math.max(
|
|
163
163
|
a.current,
|
|
164
164
|
x + 1
|
|
165
165
|
));
|
|
166
166
|
}
|
|
167
|
-
const g =
|
|
168
|
-
const x = r?.title || `Series ${m + 1}`,
|
|
169
|
-
if (!i.current.has(
|
|
167
|
+
const g = b.map((r, m) => {
|
|
168
|
+
const x = r?.title || `Series ${m + 1}`, p = o != null ? Array.isArray(o) ? o[0]?.value ?? o[0] : typeof o == "object" && "value" in o ? o.value : o : null, C = b.length === 1 ? p != null ? String(p) : "single" : r?.id || x;
|
|
169
|
+
if (!i.current.has(C)) {
|
|
170
170
|
const n = new Set(
|
|
171
171
|
Array.from(i.current.values())
|
|
172
172
|
);
|
|
173
173
|
let s = a.current;
|
|
174
|
-
for (let f = 0; f <
|
|
175
|
-
const h = (a.current + f) %
|
|
174
|
+
for (let f = 0; f < k.length; f++) {
|
|
175
|
+
const h = (a.current + f) % k.length;
|
|
176
176
|
if (!n.has(h)) {
|
|
177
177
|
s = h;
|
|
178
178
|
break;
|
|
179
179
|
}
|
|
180
180
|
}
|
|
181
|
-
i.current.set(
|
|
181
|
+
i.current.set(C, s), a.current = s + 1;
|
|
182
182
|
}
|
|
183
|
-
const oe = i.current.get(
|
|
183
|
+
const oe = i.current.get(C) ?? 0, M = ue(oe), re = [...r?.data || []].sort((n, s) => {
|
|
184
184
|
const f = typeof n.time == "number" ? n.time : Number(n.time), h = typeof s.time == "number" ? s.time : Number(s.time);
|
|
185
185
|
return f - h;
|
|
186
186
|
}).reduce((n, s) => {
|
|
187
187
|
const f = s.time;
|
|
188
188
|
return n.length === 0 || n[n.length - 1].time !== f ? n.push({ time: f, value: s.value }) : n[n.length - 1] = { time: f, value: s.value }, n;
|
|
189
|
-
}, []),
|
|
189
|
+
}, []), z = r?.lineColor ?? r?.color ?? void 0;
|
|
190
190
|
return {
|
|
191
191
|
data: re,
|
|
192
192
|
label: x,
|
|
193
193
|
yMeasureUnit: w?.[m] ?? (Array.isArray(t) ? void 0 : t),
|
|
194
|
-
...
|
|
195
|
-
lineColor:
|
|
194
|
+
...z != null ? {
|
|
195
|
+
lineColor: z,
|
|
196
196
|
...r?.topColor != null && {
|
|
197
197
|
topColor: r.topColor
|
|
198
198
|
},
|
|
@@ -200,17 +200,17 @@ function Re({
|
|
|
200
200
|
bottomColor: r.bottomColor
|
|
201
201
|
}
|
|
202
202
|
} : {
|
|
203
|
-
color:
|
|
204
|
-
topColor:
|
|
205
|
-
bottomColor:
|
|
203
|
+
color: M.line,
|
|
204
|
+
topColor: M.top,
|
|
205
|
+
bottomColor: M.bottom
|
|
206
206
|
}
|
|
207
207
|
};
|
|
208
208
|
});
|
|
209
|
-
return u && i.current.size > 0 &&
|
|
209
|
+
return u && i.current.size > 0 && F(
|
|
210
210
|
u,
|
|
211
211
|
i.current
|
|
212
212
|
), g;
|
|
213
|
-
}, [
|
|
213
|
+
}, [b, o, t, u]), te = I !== void 0 ? I.size > 0 : L && b.length > 0 ? b.some((w) => !w) : !e;
|
|
214
214
|
return /* @__PURE__ */ l(
|
|
215
215
|
"div",
|
|
216
216
|
{
|
|
@@ -227,8 +227,8 @@ function Re({
|
|
|
227
227
|
toolbar: G,
|
|
228
228
|
size: c ? "full" : "default",
|
|
229
229
|
containerClassName: se("h-full", X),
|
|
230
|
-
showLegend:
|
|
231
|
-
onUnselectSeries:
|
|
230
|
+
showLegend: L,
|
|
231
|
+
onUnselectSeries: H,
|
|
232
232
|
yMeasureUnit: P,
|
|
233
233
|
currentValueDecimals: $,
|
|
234
234
|
useSharedPriceScale: q,
|
|
@@ -20,8 +20,10 @@ const e = {
|
|
|
20
20
|
"components.loading.loadingPercent": "Loading {percent}%",
|
|
21
21
|
"components.loading.wait": "Please wait...",
|
|
22
22
|
"components.smartNumberInput.balance": "Balance",
|
|
23
|
+
"components.smartNumberInput.amountLabel": "Amount",
|
|
23
24
|
"components.smartNumberInput.inputTitle": "Token Amount",
|
|
24
25
|
"components.smartNumberInput.confirm.input": "Input",
|
|
26
|
+
"components.smartNumberInput.selectToken": "Select token",
|
|
25
27
|
"components.tipWindow.title": "Tip",
|
|
26
28
|
"components.healthFactor.low": "Extremely low! This HF may not cover possible oracle deviations.",
|
|
27
29
|
"components.headCell": "Sort by {value}",
|