@gearbox-protocol/ui-kit 2.1.0-next.1 → 3.0.1
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/README.md +7 -87
- package/dist/cjs/components/assets-list-cell/assets-list-cell.cjs +1 -1
- package/dist/cjs/components/auth/connect-required.cjs +1 -1
- package/dist/cjs/components/auth/index.cjs +1 -1
- package/dist/cjs/components/auth/signin-required.cjs +1 -1
- package/dist/cjs/components/block-sync/block-sync.cjs +1 -1
- package/dist/cjs/components/checkbox/checkbox-labeled.cjs +1 -1
- package/dist/cjs/components/client-adapters/styled-rounded-image/styled-rounded-image.cjs +1 -1
- package/dist/cjs/components/complex-input/complex-input.cjs +1 -1
- package/dist/cjs/components/compound-apy/compound-apy.cjs +1 -1
- package/dist/cjs/components/detailed-page-title/detailed-page-title.cjs +1 -1
- package/dist/cjs/components/graph/graph.cjs +1 -1
- package/dist/cjs/components/index.cjs +1 -1
- package/dist/cjs/components/markdown-viewer/markdown-viewer.cjs +1 -1
- package/dist/cjs/components/next/index.cjs +1 -1
- package/dist/cjs/components/next/siwe-provider.cjs +1 -0
- package/dist/cjs/components/table/editable-grid-table.cjs +1 -1
- package/dist/cjs/components/table/editable-table.cjs +1 -1
- package/dist/cjs/components/time-to-liquidation/time-to-liquidation.cjs +1 -1
- package/dist/cjs/components/tokens-list-cell/tokens-list-cell.cjs +1 -1
- package/dist/cjs/components/with-copy/with-copy.cjs +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/esm/components/assets-list-cell/assets-list-cell.js +4 -3
- package/dist/esm/components/auth/connect-required.js +11 -18
- package/dist/esm/components/auth/index.js +4 -5
- package/dist/esm/components/auth/signin-required.js +23 -30
- package/dist/esm/components/block-sync/block-sync.js +4 -3
- package/dist/esm/components/checkbox/checkbox-labeled.js +2 -1
- package/dist/esm/components/client-adapters/styled-rounded-image/styled-rounded-image.js +2 -1
- package/dist/esm/components/complex-input/complex-input.js +4 -3
- package/dist/esm/components/compound-apy/compound-apy.js +4 -3
- package/dist/esm/components/detailed-page-title/detailed-page-title.js +2 -1
- package/dist/esm/components/graph/graph.js +192 -182
- package/dist/esm/components/index.js +607 -608
- package/dist/esm/components/markdown-viewer/markdown-viewer.js +4 -3
- package/dist/esm/components/next/index.js +8 -6
- package/dist/esm/components/next/{connectkit/siwe-provider.js → siwe-provider.js} +1 -1
- package/dist/esm/components/table/editable-grid-table.js +37 -36
- package/dist/esm/components/table/editable-table.js +18 -17
- package/dist/esm/components/time-to-liquidation/time-to-liquidation.js +2 -1
- package/dist/esm/components/tokens-list-cell/tokens-list-cell.js +4 -3
- package/dist/esm/components/with-copy/with-copy.js +4 -3
- package/dist/esm/index.js +767 -768
- package/dist/types/components/auth/connect-required.d.ts +11 -10
- package/dist/types/components/auth/index.d.ts +1 -1
- package/dist/types/components/auth/signin-required.d.ts +5 -7
- package/dist/types/components/auth/siwe-provider.d.ts +31 -0
- package/dist/types/components/filter/filter-modal.d.ts +1 -1
- package/dist/types/components/next/index.d.ts +1 -0
- package/dist/types/components/next/siwe-provider.d.ts +7 -0
- package/dist/types/components/simple-accordion/simple-accordion.d.ts +1 -1
- package/package.json +16 -22
- package/dist/cjs/components/auth/wallet-ui-context.cjs +0 -1
- package/dist/cjs/components/connectkit/connect-kit-wallet-adapter.cjs +0 -1
- package/dist/cjs/components/connectkit/index.cjs +0 -1
- package/dist/cjs/components/next/connectkit/index.cjs +0 -1
- package/dist/cjs/components/next/connectkit/siwe-provider.cjs +0 -1
- package/dist/esm/components/auth/wallet-ui-context.js +0 -13
- package/dist/esm/components/connectkit/connect-kit-wallet-adapter.js +0 -32
- package/dist/esm/components/connectkit/index.js +0 -6
- package/dist/esm/components/next/connectkit/index.js +0 -4
- package/dist/types/components/auth/wallet-ui-context.d.ts +0 -36
- package/dist/types/components/connectkit/connect-kit-wallet-adapter.d.ts +0 -12
- package/dist/types/components/connectkit/index.d.ts +0 -2
- package/dist/types/components/connectkit/siwe-provider.d.ts +0 -30
- package/dist/types/components/next/connectkit/index.d.ts +0 -1
- package/dist/types/components/next/connectkit/siwe-provider.d.ts +0 -8
- /package/dist/cjs/components/{connectkit → auth}/siwe-provider.cjs +0 -0
- /package/dist/esm/components/{connectkit → auth}/siwe-provider.js +0 -0
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { createChart as
|
|
1
|
+
import { jsxs as X, jsx as h } from "react/jsx-runtime";
|
|
2
|
+
import { createChart as At, CrosshairMode as It, AreaSeries as zt } from "lightweight-charts";
|
|
3
3
|
import * as lt from "react";
|
|
4
|
-
import { useRef as
|
|
5
|
-
import { useIsMobile as
|
|
4
|
+
import { useRef as z, useState as it, useEffect as E } from "react";
|
|
5
|
+
import { useIsMobile as $t } from "../../hooks/use-media-query.js";
|
|
6
6
|
import { cn as ut } from "../../utils/cn.js";
|
|
7
|
-
import { resolveCSSColor as wt, generateColorsFromBase as
|
|
8
|
-
import { getDefaultOptions as Rt, getDefaultSeries as
|
|
9
|
-
import { getXFormatters as
|
|
10
|
-
import { GraphCurrentValue as
|
|
11
|
-
import { GraphTooltip as
|
|
7
|
+
import { resolveCSSColor as wt, generateColorsFromBase as K, hslToHex as Dt } from "../../utils/colors.js";
|
|
8
|
+
import { getDefaultOptions as Rt, getDefaultSeries as Et, getDefaultVerticalLine as Gt } from "./default-config.js";
|
|
9
|
+
import { getXFormatters as Vt, createAdaptiveYAxisFormatter as Bt, formatExactValue as st } from "./formatters.js";
|
|
10
|
+
import { GraphCurrentValue as Ot } from "./graph-current-value.js";
|
|
11
|
+
import { GraphTooltip as Yt } from "./graph-tooltip.js";
|
|
12
12
|
import { VertLine as jt } from "./plugins/vertical-line.js";
|
|
13
|
-
function
|
|
14
|
-
const
|
|
13
|
+
function Ht(e, v, m) {
|
|
14
|
+
const F = e.labelText ?? "", f = e.value, w = f === void 0 ? "" : typeof f == "number" ? v === "$" ? `$${st(f, void 0, m)}` : v === "%" ? `${st(f, void 0, m)}%` : st(
|
|
15
15
|
f,
|
|
16
16
|
v !== "none" && v !== "%" && v !== "$" ? v : void 0,
|
|
17
17
|
m
|
|
18
18
|
) : String(f);
|
|
19
|
-
return { labelText:
|
|
19
|
+
return { labelText: F, valueStr: w };
|
|
20
20
|
}
|
|
21
21
|
const ct = [
|
|
22
22
|
// 0 green (emerald)
|
|
@@ -133,63 +133,60 @@ const ct = [
|
|
|
133
133
|
top: "rgba(71, 85, 105, 0.56)",
|
|
134
134
|
bottom: "rgba(71, 85, 105, 0.04)"
|
|
135
135
|
}
|
|
136
|
-
],
|
|
137
|
-
function
|
|
136
|
+
], Wt = 137.5;
|
|
137
|
+
function yt(e) {
|
|
138
138
|
if (e < ct.length)
|
|
139
139
|
return ct[e];
|
|
140
|
-
const m = (e - ct.length) *
|
|
141
|
-
return { line:
|
|
140
|
+
const m = (e - ct.length) * Wt % 360, F = Dt(m, 70, 50), { topColor: f, bottomColor: w } = K(F);
|
|
141
|
+
return { line: F, top: f, bottom: w };
|
|
142
142
|
}
|
|
143
|
-
function
|
|
143
|
+
function ie({
|
|
144
144
|
series: e,
|
|
145
145
|
className: v,
|
|
146
146
|
showLegend: m = !1,
|
|
147
|
-
onUnselectSeries:
|
|
147
|
+
onUnselectSeries: F,
|
|
148
148
|
xMeasureUnit: f = "time",
|
|
149
|
-
yMeasureUnit:
|
|
150
|
-
optionsOverrides:
|
|
149
|
+
yMeasureUnit: w = "token",
|
|
150
|
+
optionsOverrides: W,
|
|
151
151
|
verticalLineOptions: C,
|
|
152
|
-
currentValueDecimals:
|
|
153
|
-
useSharedPriceScale:
|
|
152
|
+
currentValueDecimals: J,
|
|
153
|
+
useSharedPriceScale: k = !1,
|
|
154
154
|
showCurrentValue: kt = !0,
|
|
155
|
-
graphTitle:
|
|
155
|
+
graphTitle: Q,
|
|
156
156
|
yScaleMin: ft,
|
|
157
|
-
yScaleMinMultiple:
|
|
157
|
+
yScaleMinMultiple: gt
|
|
158
158
|
}) {
|
|
159
|
-
const
|
|
159
|
+
const N = z(null), R = z(/* @__PURE__ */ new Map()), U = z(!1), mt = z(!0), tt = z(
|
|
160
160
|
null
|
|
161
|
-
), Nt =
|
|
161
|
+
), Nt = z(null), $ = z(null), et = z(null), y = $t(), M = lt.useMemo(() => e.flatMap((t) => t.data), [e]), Lt = lt.useMemo(() => {
|
|
162
162
|
if (e.length > 0) {
|
|
163
163
|
const t = e[e.length - 1];
|
|
164
164
|
if (t.data.length > 0)
|
|
165
165
|
return t.data[t.data.length - 1];
|
|
166
166
|
}
|
|
167
|
-
}, [e]), [
|
|
168
|
-
if (!
|
|
167
|
+
}, [e]), [dt, ot] = it(() => {
|
|
168
|
+
if (!Lt) return;
|
|
169
169
|
const t = /* @__PURE__ */ new Map();
|
|
170
170
|
for (const a of e)
|
|
171
171
|
a.data.length > 0 && t.set(a.label, a.data[a.data.length - 1]);
|
|
172
172
|
return t;
|
|
173
|
-
}), [bt,
|
|
174
|
-
|
|
173
|
+
}), [bt, A] = it(null), [ht, pt] = it([]);
|
|
174
|
+
E(() => {
|
|
175
175
|
const t = () => {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
k.current.resize(l, s);
|
|
180
|
-
}
|
|
181
|
-
} catch {
|
|
176
|
+
if (N.current && $.current) {
|
|
177
|
+
const l = $.current.clientWidth, s = $.current.clientHeight;
|
|
178
|
+
N.current.resize(l, s);
|
|
182
179
|
}
|
|
183
180
|
}, a = $.current, r = a ? new ResizeObserver(t) : null;
|
|
184
|
-
return
|
|
185
|
-
a && r?.unobserve(a)
|
|
181
|
+
return a && r?.observe(a), () => {
|
|
182
|
+
a && r?.unobserve(a);
|
|
186
183
|
};
|
|
187
|
-
}, []),
|
|
188
|
-
if (!
|
|
184
|
+
}, []), E(() => {
|
|
185
|
+
if (!et.current || U.current) return;
|
|
189
186
|
const t = Rt(), a = wt(
|
|
190
187
|
"hsl(var(--foreground))",
|
|
191
188
|
"rgb(0, 0, 0)"
|
|
192
|
-
), r =
|
|
189
|
+
), r = At(et.current, {
|
|
193
190
|
...t,
|
|
194
191
|
rightPriceScale: {
|
|
195
192
|
...t.rightPriceScale || {},
|
|
@@ -199,32 +196,32 @@ function se({
|
|
|
199
196
|
...y && {
|
|
200
197
|
crosshair: {
|
|
201
198
|
...t.crosshair,
|
|
202
|
-
mode:
|
|
199
|
+
mode: It.Magnet
|
|
203
200
|
}
|
|
204
201
|
},
|
|
205
|
-
...
|
|
202
|
+
...W
|
|
206
203
|
});
|
|
207
|
-
return
|
|
208
|
-
|
|
204
|
+
return N.current = r, U.current = !0, () => {
|
|
205
|
+
r.remove(), N.current = null, U.current = !1, R.current.clear();
|
|
209
206
|
};
|
|
210
|
-
}, [y,
|
|
211
|
-
const t =
|
|
207
|
+
}, [y, W]), E(() => {
|
|
208
|
+
const t = N.current;
|
|
212
209
|
if (!t || e.length === 0) return;
|
|
213
|
-
const r = e.filter((o) => o.data.length > 0).length <= 1 ? ft :
|
|
210
|
+
const r = e.filter((o) => o.data.length > 0).length <= 1 ? ft : gt, l = f === "time" ? Vt(f, M) : Vt(f), s = M.map((o) => o.value), {
|
|
214
211
|
formatter: c,
|
|
215
212
|
tickmarksFormatter: u,
|
|
216
|
-
updateVisibleRange:
|
|
217
|
-
updateLastValues:
|
|
218
|
-
} = Bt(s,
|
|
213
|
+
updateVisibleRange: L,
|
|
214
|
+
updateLastValues: g
|
|
215
|
+
} = Bt(s, w, {
|
|
219
216
|
yScaleMin: r
|
|
220
217
|
});
|
|
221
|
-
|
|
218
|
+
tt.current = L, Nt.current = g;
|
|
222
219
|
const P = e.filter((o) => o.data.length > 0).map((o) => o.data[o.data.length - 1].value);
|
|
223
|
-
|
|
224
|
-
const
|
|
220
|
+
g(P);
|
|
221
|
+
const T = Rt();
|
|
225
222
|
t.applyOptions({
|
|
226
223
|
localization: {
|
|
227
|
-
...
|
|
224
|
+
...T.localization || {},
|
|
228
225
|
// biome-ignore lint/suspicious/noExplicitAny: External library type compatibility
|
|
229
226
|
timeFormatter: (o) => (
|
|
230
227
|
// biome-ignore lint/suspicious/noExplicitAny: External library type compatibility
|
|
@@ -232,21 +229,21 @@ function se({
|
|
|
232
229
|
)
|
|
233
230
|
},
|
|
234
231
|
timeScale: {
|
|
235
|
-
...
|
|
232
|
+
...T.timeScale || {},
|
|
236
233
|
// biome-ignore lint/suspicious/noExplicitAny: External library type compatibility
|
|
237
234
|
tickMarkFormatter: l.tickMarkFormatter,
|
|
238
235
|
minBarSpacing: 0
|
|
239
236
|
}
|
|
240
237
|
});
|
|
241
|
-
const
|
|
238
|
+
const d = (M.length > 0 ? Math.min(...M.map((o) => o.value)) : 0) < 0, x = M.some((o) => o.value === 0), b = !d && x, p = e.length > 1 && !k, S = e.length > 1 && !k || y, I = wt(
|
|
242
239
|
"hsl(var(--foreground))",
|
|
243
240
|
"rgb(0, 0, 0)"
|
|
244
241
|
);
|
|
245
242
|
t.applyOptions({
|
|
246
243
|
rightPriceScale: {
|
|
247
|
-
...
|
|
248
|
-
visible: !
|
|
249
|
-
textColor:
|
|
244
|
+
...T.rightPriceScale || {},
|
|
245
|
+
visible: !S,
|
|
246
|
+
textColor: I,
|
|
250
247
|
...b && {
|
|
251
248
|
scaleMargins: {
|
|
252
249
|
top: 0.3,
|
|
@@ -255,46 +252,46 @@ function se({
|
|
|
255
252
|
}
|
|
256
253
|
}
|
|
257
254
|
});
|
|
258
|
-
const
|
|
259
|
-
for (const o of
|
|
260
|
-
if (!
|
|
261
|
-
const n =
|
|
262
|
-
n && (t.removeSeries(n),
|
|
255
|
+
const D = new Set(R.current.keys()), G = new Set(e.map((o) => o.label));
|
|
256
|
+
for (const o of D)
|
|
257
|
+
if (!G.has(o)) {
|
|
258
|
+
const n = R.current.get(o);
|
|
259
|
+
n && (t.removeSeries(n), R.current.delete(o));
|
|
263
260
|
}
|
|
264
|
-
const
|
|
265
|
-
let
|
|
261
|
+
const B = Et(), rt = [];
|
|
262
|
+
let Z = 0;
|
|
266
263
|
for (let o = 0; o < e.length; o++) {
|
|
267
|
-
const n = e[o],
|
|
268
|
-
let
|
|
264
|
+
const n = e[o], _ = yt(o), O = n.lineColor ?? n.color ?? _.line;
|
|
265
|
+
let Y, j;
|
|
269
266
|
if (n.lineColor ?? n.color)
|
|
270
267
|
if (n.topColor && n.bottomColor)
|
|
271
|
-
|
|
268
|
+
Y = n.topColor, j = n.bottomColor;
|
|
272
269
|
else if (n.topColor) {
|
|
273
|
-
const i =
|
|
274
|
-
|
|
270
|
+
const i = K(O);
|
|
271
|
+
Y = n.topColor, j = i.bottomColor;
|
|
275
272
|
} else if (n.bottomColor)
|
|
276
|
-
|
|
273
|
+
Y = K(O).topColor, j = n.bottomColor;
|
|
277
274
|
else {
|
|
278
|
-
const i =
|
|
279
|
-
|
|
275
|
+
const i = K(O);
|
|
276
|
+
Y = i.topColor, j = i.bottomColor;
|
|
280
277
|
}
|
|
281
278
|
else
|
|
282
|
-
|
|
279
|
+
Y = n.topColor || _.top, j = n.bottomColor || _.bottom;
|
|
283
280
|
if (n.data.length === 0) {
|
|
284
|
-
const i =
|
|
285
|
-
i && (t.removeSeries(i),
|
|
281
|
+
const i = R.current.get(n.label);
|
|
282
|
+
i && (t.removeSeries(i), R.current.delete(n.label));
|
|
286
283
|
continue;
|
|
287
284
|
}
|
|
288
|
-
const
|
|
285
|
+
const Pt = (n.data.length > 0 ? Math.min(...n.data.map((i) => i.value)) : 0) < 0, Tt = n.data.some((i) => i.value === 0), Ft = !Pt && Tt, Ct = k || !p || Z === 0 ? "right" : `scale-${Z}`;
|
|
289
286
|
p && rt.push({
|
|
290
287
|
priceScaleId: Ct || "right",
|
|
291
|
-
shouldPreventNegativeAxis:
|
|
292
|
-
seriesIndex:
|
|
288
|
+
shouldPreventNegativeAxis: Ft,
|
|
289
|
+
seriesIndex: Z
|
|
293
290
|
});
|
|
294
|
-
const xt = (
|
|
295
|
-
lineColor:
|
|
296
|
-
topColor:
|
|
297
|
-
bottomColor:
|
|
291
|
+
const xt = (k || !p) && r !== void 0 && typeof r == "number", St = {
|
|
292
|
+
lineColor: O,
|
|
293
|
+
topColor: Y,
|
|
294
|
+
bottomColor: j,
|
|
298
295
|
priceScaleId: Ct,
|
|
299
296
|
priceFormat: {
|
|
300
297
|
type: "custom",
|
|
@@ -308,27 +305,27 @@ function se({
|
|
|
308
305
|
if (!xt) return i();
|
|
309
306
|
const at = i();
|
|
310
307
|
if (at?.priceRange) {
|
|
311
|
-
const
|
|
312
|
-
at.priceRange.minValue =
|
|
308
|
+
const Mt = r;
|
|
309
|
+
at.priceRange.minValue = Mt;
|
|
313
310
|
}
|
|
314
311
|
return at;
|
|
315
312
|
}
|
|
316
313
|
};
|
|
317
|
-
let
|
|
318
|
-
|
|
314
|
+
let H = R.current.get(n.label);
|
|
315
|
+
H ? (H.applyOptions(St), H.setData(
|
|
319
316
|
n.data.map((i) => ({
|
|
320
317
|
...i,
|
|
321
318
|
time: i.time
|
|
322
319
|
}))
|
|
323
|
-
)) : (
|
|
324
|
-
...
|
|
320
|
+
)) : (H = t.addSeries(zt, {
|
|
321
|
+
...B,
|
|
325
322
|
...St
|
|
326
|
-
}),
|
|
323
|
+
}), H.setData(
|
|
327
324
|
n.data.map((i) => ({
|
|
328
325
|
...i,
|
|
329
326
|
time: i.time
|
|
330
327
|
}))
|
|
331
|
-
),
|
|
328
|
+
), R.current.set(n.label, H)), Z++;
|
|
332
329
|
}
|
|
333
330
|
if (p && rt.length > 0)
|
|
334
331
|
for (const o of rt)
|
|
@@ -349,7 +346,7 @@ function se({
|
|
|
349
346
|
borderVisible: !0,
|
|
350
347
|
borderColor: "rgba(224, 227, 235, 0.1)",
|
|
351
348
|
entireTextOnly: !1,
|
|
352
|
-
textColor:
|
|
349
|
+
textColor: I
|
|
353
350
|
});
|
|
354
351
|
} catch (n) {
|
|
355
352
|
console.warn(
|
|
@@ -375,34 +372,34 @@ function se({
|
|
|
375
372
|
borderVisible: !0,
|
|
376
373
|
borderColor: "rgba(224, 227, 235, 0.1)",
|
|
377
374
|
entireTextOnly: !1,
|
|
378
|
-
textColor:
|
|
375
|
+
textColor: I
|
|
379
376
|
});
|
|
380
377
|
} catch {
|
|
381
378
|
}
|
|
382
|
-
if (r !== void 0 && !y && (
|
|
379
|
+
if (r !== void 0 && !y && (k || !p) && t.applyOptions({
|
|
383
380
|
handleScroll: {
|
|
384
381
|
vertTouchDrag: !1
|
|
385
382
|
}
|
|
386
|
-
}),
|
|
387
|
-
const o =
|
|
388
|
-
t.timeScale().setVisibleRange({ from: n, to:
|
|
383
|
+
}), M.length > 0) {
|
|
384
|
+
const o = M.map((O) => Number(O.time)), n = Math.min(...o), _ = Math.max(...o);
|
|
385
|
+
t.timeScale().setVisibleRange({ from: n, to: _ });
|
|
389
386
|
}
|
|
390
|
-
|
|
387
|
+
mt.current && (mt.current = !1);
|
|
391
388
|
const nt = /* @__PURE__ */ new Map();
|
|
392
389
|
for (const o of e)
|
|
393
390
|
o.data.length > 0 && nt.set(o.label, o.data[o.data.length - 1]);
|
|
394
|
-
|
|
391
|
+
ot(nt.size > 0 ? nt : void 0);
|
|
395
392
|
}, [
|
|
396
393
|
e,
|
|
397
|
-
|
|
394
|
+
M,
|
|
398
395
|
f,
|
|
399
|
-
|
|
396
|
+
w,
|
|
400
397
|
y,
|
|
401
|
-
|
|
398
|
+
k,
|
|
402
399
|
ft,
|
|
403
|
-
|
|
404
|
-
]),
|
|
405
|
-
const t =
|
|
400
|
+
gt
|
|
401
|
+
]), E(() => {
|
|
402
|
+
const t = N.current;
|
|
406
403
|
if (!t || e.length === 0) return;
|
|
407
404
|
const a = e.length === 1;
|
|
408
405
|
let r;
|
|
@@ -413,83 +410,96 @@ function se({
|
|
|
413
410
|
}
|
|
414
411
|
if (!r) return;
|
|
415
412
|
const l = (s) => {
|
|
416
|
-
const { time: c = r, seriesData: u, point:
|
|
417
|
-
if (!
|
|
418
|
-
const
|
|
419
|
-
for (const
|
|
420
|
-
|
|
421
|
-
if (
|
|
422
|
-
|
|
423
|
-
else if (
|
|
413
|
+
const { time: c = r, seriesData: u, point: L } = s || {}, g = Array.from(R.current.values());
|
|
414
|
+
if (!L || !c) {
|
|
415
|
+
const V = /* @__PURE__ */ new Map();
|
|
416
|
+
for (const d of e)
|
|
417
|
+
d.data.length > 0 && V.set(d.label, d.data[d.data.length - 1]);
|
|
418
|
+
if (ot(V.size > 0 ? V : void 0), a || k)
|
|
419
|
+
A(null);
|
|
420
|
+
else if (g[0] && r) {
|
|
424
421
|
const x = t.timeScale().timeToCoordinate(r), b = e[0];
|
|
425
422
|
if (b.data.length > 0) {
|
|
426
|
-
const p = b.data[b.data.length - 1].value,
|
|
427
|
-
x !== null &&
|
|
423
|
+
const p = b.data[b.data.length - 1].value, S = g[0].priceToCoordinate(p);
|
|
424
|
+
x !== null && S !== null && A({ x, y: S });
|
|
428
425
|
}
|
|
429
426
|
}
|
|
430
427
|
return;
|
|
431
428
|
}
|
|
432
429
|
const P = /* @__PURE__ */ new Map();
|
|
433
|
-
let
|
|
434
|
-
for (let
|
|
435
|
-
const
|
|
430
|
+
let T;
|
|
431
|
+
for (let V = 0; V < e.length; V++) {
|
|
432
|
+
const d = e[V], x = g[V];
|
|
436
433
|
if (!x) continue;
|
|
437
|
-
const b = u?.get(x), p = b && "value" in b ? b.value : void 0
|
|
438
|
-
|
|
434
|
+
const b = u?.get(x), p = b && "value" in b ? b.value : void 0;
|
|
435
|
+
let S;
|
|
436
|
+
if (p !== void 0)
|
|
437
|
+
S = p;
|
|
438
|
+
else {
|
|
439
|
+
const I = Number(c), D = d.data;
|
|
440
|
+
let G = 0;
|
|
441
|
+
for (let B = D.length - 1; B >= 0; B--)
|
|
442
|
+
if (Number(D[B].time) <= I) {
|
|
443
|
+
G = D[B].value;
|
|
444
|
+
break;
|
|
445
|
+
}
|
|
446
|
+
S = G;
|
|
447
|
+
}
|
|
448
|
+
V === 0 && (T = S), P.set(d.label, { value: S, time: c });
|
|
439
449
|
}
|
|
440
|
-
if (
|
|
441
|
-
const
|
|
442
|
-
if (
|
|
450
|
+
if (ot(P), T !== void 0 && g[0]) {
|
|
451
|
+
const d = t.timeScale().timeToCoordinate(c), x = g[0].priceToCoordinate(T);
|
|
452
|
+
if (d !== null && x !== null) {
|
|
443
453
|
const b = $.current;
|
|
444
454
|
if (b) {
|
|
445
455
|
const p = b.querySelector(
|
|
446
456
|
".LightweightChart"
|
|
447
457
|
);
|
|
448
458
|
if (p) {
|
|
449
|
-
const
|
|
450
|
-
|
|
459
|
+
const S = p.getBoundingClientRect(), I = b.getBoundingClientRect(), D = d + (S.left - I.left), G = x + (S.top - I.top);
|
|
460
|
+
A({ x: D, y: G });
|
|
451
461
|
} else
|
|
452
|
-
|
|
462
|
+
A({ x: d, y: x });
|
|
453
463
|
} else
|
|
454
|
-
|
|
464
|
+
A({ x: d, y: x });
|
|
455
465
|
} else
|
|
456
|
-
|
|
466
|
+
A(null);
|
|
457
467
|
} else
|
|
458
|
-
|
|
468
|
+
A(null);
|
|
459
469
|
};
|
|
460
|
-
return t.subscribeCrosshairMove(l), y && t.subscribeClick(l), !a && !
|
|
461
|
-
const s = Array.from(
|
|
470
|
+
return t.subscribeCrosshairMove(l), y && t.subscribeClick(l), !a && !k && requestAnimationFrame(() => {
|
|
471
|
+
const s = Array.from(R.current.values());
|
|
462
472
|
if (s[0] && r && e[0]?.data.length > 0) {
|
|
463
|
-
const u = t.timeScale().timeToCoordinate(r),
|
|
464
|
-
u !== null &&
|
|
473
|
+
const u = t.timeScale().timeToCoordinate(r), L = e[0].data[e[0].data.length - 1].value, g = s[0].priceToCoordinate(L);
|
|
474
|
+
u !== null && g !== null && A({ x: u, y: g });
|
|
465
475
|
}
|
|
466
476
|
}), () => {
|
|
467
477
|
t.unsubscribeCrosshairMove(l), y && t.unsubscribeClick(l);
|
|
468
478
|
};
|
|
469
|
-
}, [e,
|
|
470
|
-
const t =
|
|
479
|
+
}, [e, k, y]), E(() => {
|
|
480
|
+
const t = N.current;
|
|
471
481
|
if (!t || e.length === 0) return;
|
|
472
482
|
const a = t.timeScale(), r = () => {
|
|
473
|
-
if (!
|
|
483
|
+
if (!tt.current) return;
|
|
474
484
|
const l = a.getVisibleRange();
|
|
475
485
|
if (!l) return;
|
|
476
486
|
const s = Number(l.from), c = Number(l.to), u = [];
|
|
477
|
-
for (const
|
|
478
|
-
for (const
|
|
479
|
-
const P = Number(
|
|
480
|
-
P >= s && P <= c && u.push(
|
|
487
|
+
for (const L of e)
|
|
488
|
+
for (const g of L.data) {
|
|
489
|
+
const P = Number(g.time);
|
|
490
|
+
P >= s && P <= c && u.push(g.value);
|
|
481
491
|
}
|
|
482
|
-
u.length > 0 &&
|
|
492
|
+
u.length > 0 && tt.current(u);
|
|
483
493
|
};
|
|
484
494
|
return a.subscribeVisibleLogicalRangeChange(r), () => {
|
|
485
495
|
a.unsubscribeVisibleLogicalRangeChange(
|
|
486
496
|
r
|
|
487
497
|
);
|
|
488
498
|
};
|
|
489
|
-
}, [e]),
|
|
490
|
-
const t =
|
|
499
|
+
}, [e]), E(() => {
|
|
500
|
+
const t = N.current, a = Array.from(R.current.values()), r = [];
|
|
491
501
|
if (t && a.length > 0 && C) {
|
|
492
|
-
const l =
|
|
502
|
+
const l = Gt(), s = a[0];
|
|
493
503
|
for (const c of C) {
|
|
494
504
|
const u = new jt(t, s, c.xCoordinate, {
|
|
495
505
|
...l,
|
|
@@ -505,8 +515,8 @@ function se({
|
|
|
505
515
|
l.detachPrimitive(s);
|
|
506
516
|
}
|
|
507
517
|
};
|
|
508
|
-
}, [C]),
|
|
509
|
-
const t =
|
|
518
|
+
}, [C]), E(() => {
|
|
519
|
+
const t = N.current;
|
|
510
520
|
if (!t || !C?.length) {
|
|
511
521
|
pt([]);
|
|
512
522
|
return;
|
|
@@ -523,14 +533,14 @@ function se({
|
|
|
523
533
|
r.unsubscribeVisibleLogicalRangeChange(l);
|
|
524
534
|
};
|
|
525
535
|
}, [C]);
|
|
526
|
-
const
|
|
527
|
-
if (
|
|
536
|
+
const q = e.length === 1, vt = lt.useMemo(() => {
|
|
537
|
+
if (q && e.length > 0) {
|
|
528
538
|
const t = e[0];
|
|
529
539
|
if (t.data.length > 0)
|
|
530
540
|
return t.data[t.data.length - 1];
|
|
531
541
|
}
|
|
532
|
-
}, [
|
|
533
|
-
return /* @__PURE__ */
|
|
542
|
+
}, [q, e]);
|
|
543
|
+
return /* @__PURE__ */ X(
|
|
534
544
|
"div",
|
|
535
545
|
{
|
|
536
546
|
ref: $,
|
|
@@ -539,28 +549,28 @@ function se({
|
|
|
539
549
|
v
|
|
540
550
|
),
|
|
541
551
|
children: [
|
|
542
|
-
|
|
543
|
-
|
|
552
|
+
Q != null && Q !== !1 && q ? /* @__PURE__ */ h("div", { className: "absolute top-2 left-2 right-2 z-[100] pointer-events-none", children: /* @__PURE__ */ h("div", { className: "text-xl sm:text-2xl font-semibold text-foreground whitespace-nowrap overflow-hidden text-ellipsis", children: Q }) }) : kt && q && vt && /* @__PURE__ */ h(
|
|
553
|
+
Ot,
|
|
544
554
|
{
|
|
545
555
|
point: vt,
|
|
546
556
|
xMeasureUnit: f,
|
|
547
|
-
yMeasureUnit:
|
|
548
|
-
decimals:
|
|
557
|
+
yMeasureUnit: w,
|
|
558
|
+
decimals: J
|
|
549
559
|
}
|
|
550
560
|
),
|
|
551
|
-
|
|
552
|
-
|
|
561
|
+
dt && bt && /* @__PURE__ */ h(
|
|
562
|
+
Yt,
|
|
553
563
|
{
|
|
554
|
-
points:
|
|
564
|
+
points: dt,
|
|
555
565
|
xMeasureUnit: f,
|
|
556
|
-
yMeasureUnit:
|
|
566
|
+
yMeasureUnit: w,
|
|
557
567
|
series: e,
|
|
558
568
|
position: bt,
|
|
559
569
|
containerRef: $,
|
|
560
|
-
decimals:
|
|
570
|
+
decimals: J
|
|
561
571
|
}
|
|
562
572
|
),
|
|
563
|
-
m && /* @__PURE__ */ h(
|
|
573
|
+
m && /* @__PURE__ */ h(_t, { series: e, onUnselect: F }),
|
|
564
574
|
C && C.length > 0 && ht.length === C.length && /* @__PURE__ */ h(
|
|
565
575
|
"div",
|
|
566
576
|
{
|
|
@@ -569,21 +579,21 @@ function se({
|
|
|
569
579
|
children: C.map((t, a) => {
|
|
570
580
|
const r = ht[a], l = t.options ?? {}, s = l.showLabel !== !1;
|
|
571
581
|
if (r === null || !s) return null;
|
|
572
|
-
const { labelText: c, valueStr: u } =
|
|
582
|
+
const { labelText: c, valueStr: u } = Ht(
|
|
573
583
|
l,
|
|
574
|
-
|
|
575
|
-
|
|
584
|
+
w,
|
|
585
|
+
J
|
|
576
586
|
);
|
|
577
587
|
if (!(c || u)) return null;
|
|
578
|
-
const
|
|
579
|
-
return /* @__PURE__ */
|
|
588
|
+
const g = l.labelBackgroundColor ?? l.color ?? "hsl(var(--background))", P = l.labelTextColor ?? "hsl(var(--foreground))", T = `${String(t.xCoordinate)}-${c}`;
|
|
589
|
+
return /* @__PURE__ */ X(
|
|
580
590
|
"div",
|
|
581
591
|
{
|
|
582
592
|
className: "absolute top-2 px-2 py-1 rounded text-xs font-medium whitespace-nowrap shadow-sm border border-border",
|
|
583
593
|
style: {
|
|
584
594
|
left: r,
|
|
585
595
|
transform: "translateX(-50%)",
|
|
586
|
-
backgroundColor:
|
|
596
|
+
backgroundColor: g,
|
|
587
597
|
color: P
|
|
588
598
|
},
|
|
589
599
|
children: [
|
|
@@ -591,7 +601,7 @@ function se({
|
|
|
591
601
|
u && /* @__PURE__ */ h("span", { className: ut("block", c && "mt-0.5"), children: u })
|
|
592
602
|
]
|
|
593
603
|
},
|
|
594
|
-
|
|
604
|
+
T
|
|
595
605
|
);
|
|
596
606
|
})
|
|
597
607
|
}
|
|
@@ -599,7 +609,7 @@ function se({
|
|
|
599
609
|
/* @__PURE__ */ h(
|
|
600
610
|
"div",
|
|
601
611
|
{
|
|
602
|
-
ref:
|
|
612
|
+
ref: et,
|
|
603
613
|
className: "LightweightChart w-full h-full overflow-hidden"
|
|
604
614
|
}
|
|
605
615
|
)
|
|
@@ -607,30 +617,30 @@ function se({
|
|
|
607
617
|
}
|
|
608
618
|
);
|
|
609
619
|
}
|
|
610
|
-
function
|
|
620
|
+
function _t({
|
|
611
621
|
series: e,
|
|
612
622
|
onUnselect: v
|
|
613
623
|
}) {
|
|
614
|
-
return /* @__PURE__ */ h("div", { className: "absolute top-0 left-2 z-[10] flex flex-wrap gap-2", children: e.map((m,
|
|
615
|
-
const f =
|
|
616
|
-
return /* @__PURE__ */
|
|
624
|
+
return /* @__PURE__ */ h("div", { className: "absolute top-0 left-2 z-[10] flex flex-wrap gap-2", children: e.map((m, F) => {
|
|
625
|
+
const f = yt(F), w = (m.lineColor ?? m.color) || f.line, W = m.data.length === 0;
|
|
626
|
+
return /* @__PURE__ */ X(
|
|
617
627
|
"div",
|
|
618
628
|
{
|
|
619
629
|
className: ut(
|
|
620
630
|
"flex items-center gap-1.5 px-2 py-1 bg-background/80 backdrop-blur-sm rounded border border-border",
|
|
621
|
-
|
|
631
|
+
W && "opacity-50"
|
|
622
632
|
),
|
|
623
633
|
children: [
|
|
624
634
|
/* @__PURE__ */ h(
|
|
625
635
|
"div",
|
|
626
636
|
{
|
|
627
637
|
className: "w-3 h-3 rounded-sm",
|
|
628
|
-
style: { backgroundColor:
|
|
638
|
+
style: { backgroundColor: w }
|
|
629
639
|
}
|
|
630
640
|
),
|
|
631
|
-
/* @__PURE__ */
|
|
641
|
+
/* @__PURE__ */ X("span", { className: "text-[10px] sm:text-xs font-medium text-foreground", children: [
|
|
632
642
|
m.label,
|
|
633
|
-
|
|
643
|
+
W && " (no data)"
|
|
634
644
|
] }),
|
|
635
645
|
v && /* @__PURE__ */ h(
|
|
636
646
|
"button",
|
|
@@ -641,7 +651,7 @@ function Xt({
|
|
|
641
651
|
},
|
|
642
652
|
className: "ml-1 flex items-center justify-center w-4 h-4 rounded-sm hover:bg-muted transition-colors cursor-pointer",
|
|
643
653
|
"aria-label": `Remove ${m.label}`,
|
|
644
|
-
children: /* @__PURE__ */
|
|
654
|
+
children: /* @__PURE__ */ X(
|
|
645
655
|
"svg",
|
|
646
656
|
{
|
|
647
657
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -672,7 +682,7 @@ function Xt({
|
|
|
672
682
|
}
|
|
673
683
|
export {
|
|
674
684
|
ct as DEFAULT_SERIES_COLORS,
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
685
|
+
ie as Graph,
|
|
686
|
+
yt as getSeriesColorPalette,
|
|
687
|
+
Ht as getVerticalLineTooltipContent
|
|
678
688
|
};
|