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