@gearbox-protocol/ui-kit 3.0.0 → 3.1.0-next.2
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 +167 -164
- 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 j, jsx as h } 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
|
|
2
|
+
import { createChart as It, CrosshairMode as zt, AreaSeries as $t } from "lightweight-charts";
|
|
3
|
+
import * as lt from "react";
|
|
4
|
+
import { useRef as M, useState as it, useEffect as D } from "react";
|
|
5
|
+
import { useIsMobile as Dt } from "../../hooks/use-media-query.js";
|
|
6
|
+
import { cn as ut } from "../../utils/cn.js";
|
|
7
|
+
import { resolveCSSColor as wt, generateColorsFromBase as q, hslToHex as Et } from "../../utils/colors.js";
|
|
8
|
+
import { getDefaultOptions as Rt, getDefaultSeries as Gt, getDefaultVerticalLine as Ot } from "./default-config.js";
|
|
9
|
+
import { getXFormatters as yt, createAdaptiveYAxisFormatter as Bt, formatExactValue as st } from "./formatters.js";
|
|
10
|
+
import { GraphCurrentValue as Yt } from "./graph-current-value.js";
|
|
11
|
+
import { GraphTooltip as Ht } from "./graph-tooltip.js";
|
|
12
|
+
import { VertLine as jt } from "./plugins/vertical-line.js";
|
|
13
|
+
function Wt(e, v, m) {
|
|
14
|
+
const A = e.labelText ?? "", f = e.value, S = 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: A, valueStr: S };
|
|
20
20
|
}
|
|
21
|
-
const
|
|
21
|
+
const ct = [
|
|
22
22
|
// 0 green (emerald)
|
|
23
23
|
{
|
|
24
24
|
line: "#02c39a",
|
|
@@ -133,92 +133,95 @@ const st = [
|
|
|
133
133
|
top: "rgba(71, 85, 105, 0.56)",
|
|
134
134
|
bottom: "rgba(71, 85, 105, 0.04)"
|
|
135
135
|
}
|
|
136
|
-
],
|
|
136
|
+
], _t = 137.5;
|
|
137
137
|
function Vt(e) {
|
|
138
|
-
if (e <
|
|
139
|
-
return
|
|
140
|
-
const m = (e -
|
|
141
|
-
return { line:
|
|
138
|
+
if (e < ct.length)
|
|
139
|
+
return ct[e];
|
|
140
|
+
const m = (e - ct.length) * _t % 360, A = Et(m, 70, 50), { topColor: f, bottomColor: S } = q(A);
|
|
141
|
+
return { line: A, top: f, bottom: S };
|
|
142
142
|
}
|
|
143
|
-
function
|
|
143
|
+
function se({
|
|
144
144
|
series: e,
|
|
145
145
|
className: v,
|
|
146
146
|
showLegend: m = !1,
|
|
147
|
-
onUnselectSeries:
|
|
147
|
+
onUnselectSeries: A,
|
|
148
148
|
xMeasureUnit: f = "time",
|
|
149
149
|
yMeasureUnit: S = "token",
|
|
150
150
|
optionsOverrides: Y,
|
|
151
151
|
verticalLineOptions: C,
|
|
152
|
-
currentValueDecimals:
|
|
153
|
-
useSharedPriceScale:
|
|
154
|
-
showCurrentValue:
|
|
155
|
-
graphTitle:
|
|
156
|
-
yScaleMin:
|
|
157
|
-
yScaleMinMultiple:
|
|
152
|
+
currentValueDecimals: Z,
|
|
153
|
+
useSharedPriceScale: V = !1,
|
|
154
|
+
showCurrentValue: kt = !0,
|
|
155
|
+
graphTitle: K,
|
|
156
|
+
yScaleMin: ft,
|
|
157
|
+
yScaleMinMultiple: dt
|
|
158
158
|
}) {
|
|
159
|
-
const k =
|
|
159
|
+
const k = M(null), w = M(/* @__PURE__ */ new Map()), J = M(!1), gt = M(!0), Q = M(
|
|
160
160
|
null
|
|
161
|
-
),
|
|
161
|
+
), Nt = M(null), $ = M(null), U = M(null), W = M(null), y = Dt(), I = lt.useMemo(() => e.flatMap((t) => t.data), [e]), Pt = 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]), [mt, tt] = it(() => {
|
|
168
|
+
if (!Pt) 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
|
-
}), [
|
|
173
|
+
}), [bt, z] = it(null), [ht, pt] = it([]);
|
|
174
174
|
D(() => {
|
|
175
175
|
const t = () => {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
176
|
+
try {
|
|
177
|
+
if (k.current && $.current) {
|
|
178
|
+
const l = $.current.clientWidth, s = $.current.clientHeight;
|
|
179
|
+
k.current.resize(l, s);
|
|
180
|
+
}
|
|
181
|
+
} catch {
|
|
179
182
|
}
|
|
180
183
|
}, a = $.current, r = a ? new ResizeObserver(t) : null;
|
|
181
|
-
return a && r?.observe(a), () => {
|
|
182
|
-
a && r?.unobserve(a);
|
|
184
|
+
return W.current = r, a && r?.observe(a), () => {
|
|
185
|
+
a && r?.unobserve(a), r?.disconnect(), W.current = null;
|
|
183
186
|
};
|
|
184
187
|
}, []), D(() => {
|
|
185
|
-
if (!
|
|
186
|
-
const t =
|
|
188
|
+
if (!U.current || J.current) return;
|
|
189
|
+
const t = Rt(), a = wt(
|
|
187
190
|
"hsl(var(--foreground))",
|
|
188
191
|
"rgb(0, 0, 0)"
|
|
189
|
-
), r =
|
|
192
|
+
), r = It(U.current, {
|
|
190
193
|
...t,
|
|
191
194
|
rightPriceScale: {
|
|
192
195
|
...t.rightPriceScale || {},
|
|
193
|
-
visible: !
|
|
196
|
+
visible: !y,
|
|
194
197
|
textColor: a
|
|
195
198
|
},
|
|
196
|
-
...
|
|
199
|
+
...y && {
|
|
197
200
|
crosshair: {
|
|
198
201
|
...t.crosshair,
|
|
199
|
-
mode:
|
|
202
|
+
mode: zt.Magnet
|
|
200
203
|
}
|
|
201
204
|
},
|
|
202
205
|
...Y
|
|
203
206
|
});
|
|
204
|
-
return k.current = r,
|
|
205
|
-
r.remove(), k.current = null,
|
|
207
|
+
return k.current = r, J.current = !0, () => {
|
|
208
|
+
W.current?.disconnect(), W.current = null, r.remove(), k.current = null, J.current = !1, w.current.clear();
|
|
206
209
|
};
|
|
207
|
-
}, [
|
|
210
|
+
}, [y, Y]), D(() => {
|
|
208
211
|
const t = k.current;
|
|
209
212
|
if (!t || e.length === 0) return;
|
|
210
|
-
const r = e.filter((o) => o.data.length > 0).length <= 1 ?
|
|
213
|
+
const r = e.filter((o) => o.data.length > 0).length <= 1 ? ft : dt, l = f === "time" ? yt(f, I) : yt(f), s = I.map((o) => o.value), {
|
|
211
214
|
formatter: c,
|
|
212
215
|
tickmarksFormatter: u,
|
|
213
216
|
updateVisibleRange: N,
|
|
214
|
-
updateLastValues:
|
|
217
|
+
updateLastValues: d
|
|
215
218
|
} = Bt(s, S, {
|
|
216
219
|
yScaleMin: r
|
|
217
220
|
});
|
|
218
|
-
|
|
221
|
+
Q.current = N, Nt.current = d;
|
|
219
222
|
const P = e.filter((o) => o.data.length > 0).map((o) => o.data[o.data.length - 1].value);
|
|
220
|
-
|
|
221
|
-
const L =
|
|
223
|
+
d(P);
|
|
224
|
+
const L = Rt();
|
|
222
225
|
t.applyOptions({
|
|
223
226
|
localization: {
|
|
224
227
|
...L.localization || {},
|
|
@@ -235,7 +238,7 @@ function ie({
|
|
|
235
238
|
minBarSpacing: 0
|
|
236
239
|
}
|
|
237
240
|
});
|
|
238
|
-
const
|
|
241
|
+
const g = (I.length > 0 ? Math.min(...I.map((o) => o.value)) : 0) < 0, x = I.some((o) => o.value === 0), b = !g && x, p = e.length > 1 && !V, T = e.length > 1 && !V || y, F = wt(
|
|
239
242
|
"hsl(var(--foreground))",
|
|
240
243
|
"rgb(0, 0, 0)"
|
|
241
244
|
);
|
|
@@ -252,83 +255,83 @@ function ie({
|
|
|
252
255
|
}
|
|
253
256
|
}
|
|
254
257
|
});
|
|
255
|
-
const
|
|
256
|
-
for (const o of
|
|
257
|
-
if (!
|
|
258
|
+
const et = new Set(w.current.keys()), ot = new Set(e.map((o) => o.label));
|
|
259
|
+
for (const o of et)
|
|
260
|
+
if (!ot.has(o)) {
|
|
258
261
|
const n = w.current.get(o);
|
|
259
262
|
n && (t.removeSeries(n), w.current.delete(o));
|
|
260
263
|
}
|
|
261
|
-
const
|
|
262
|
-
let
|
|
264
|
+
const Lt = Gt(), rt = [];
|
|
265
|
+
let X = 0;
|
|
263
266
|
for (let o = 0; o < e.length; o++) {
|
|
264
267
|
const n = e[o], H = Vt(o), E = n.lineColor ?? n.color ?? H.line;
|
|
265
|
-
let G,
|
|
268
|
+
let G, O;
|
|
266
269
|
if (n.lineColor ?? n.color)
|
|
267
270
|
if (n.topColor && n.bottomColor)
|
|
268
|
-
G = n.topColor,
|
|
271
|
+
G = n.topColor, O = n.bottomColor;
|
|
269
272
|
else if (n.topColor) {
|
|
270
|
-
const i =
|
|
271
|
-
G = n.topColor,
|
|
273
|
+
const i = q(E);
|
|
274
|
+
G = n.topColor, O = i.bottomColor;
|
|
272
275
|
} else if (n.bottomColor)
|
|
273
|
-
G =
|
|
276
|
+
G = q(E).topColor, O = n.bottomColor;
|
|
274
277
|
else {
|
|
275
|
-
const i =
|
|
276
|
-
G = i.topColor,
|
|
278
|
+
const i = q(E);
|
|
279
|
+
G = i.topColor, O = i.bottomColor;
|
|
277
280
|
}
|
|
278
281
|
else
|
|
279
|
-
G = n.topColor || H.top,
|
|
282
|
+
G = n.topColor || H.top, O = n.bottomColor || H.bottom;
|
|
280
283
|
if (n.data.length === 0) {
|
|
281
284
|
const i = w.current.get(n.label);
|
|
282
285
|
i && (t.removeSeries(i), w.current.delete(n.label));
|
|
283
286
|
continue;
|
|
284
287
|
}
|
|
285
|
-
const
|
|
286
|
-
p &&
|
|
287
|
-
priceScaleId:
|
|
288
|
-
shouldPreventNegativeAxis:
|
|
289
|
-
seriesIndex:
|
|
288
|
+
const Tt = (n.data.length > 0 ? Math.min(...n.data.map((i) => i.value)) : 0) < 0, Ft = n.data.some((i) => i.value === 0), Mt = !Tt && Ft, Ct = V || !p || X === 0 ? "right" : `scale-${X}`;
|
|
289
|
+
p && rt.push({
|
|
290
|
+
priceScaleId: Ct || "right",
|
|
291
|
+
shouldPreventNegativeAxis: Mt,
|
|
292
|
+
seriesIndex: X
|
|
290
293
|
});
|
|
291
|
-
const
|
|
294
|
+
const xt = (V || !p) && r !== void 0 && typeof r == "number", St = {
|
|
292
295
|
lineColor: E,
|
|
293
296
|
topColor: G,
|
|
294
|
-
bottomColor:
|
|
295
|
-
priceScaleId:
|
|
297
|
+
bottomColor: O,
|
|
298
|
+
priceScaleId: Ct,
|
|
296
299
|
priceFormat: {
|
|
297
300
|
type: "custom",
|
|
298
301
|
minMove: 0.01,
|
|
299
|
-
formatter:
|
|
302
|
+
formatter: xt && typeof r == "number" ? (i) => c(
|
|
300
303
|
i < r ? r : i
|
|
301
304
|
) : c,
|
|
302
305
|
tickmarksFormatter: u
|
|
303
306
|
},
|
|
304
307
|
autoscaleInfoProvider: (i) => {
|
|
305
|
-
if (!
|
|
306
|
-
const
|
|
307
|
-
if (
|
|
308
|
-
const
|
|
309
|
-
|
|
308
|
+
if (!xt) return i();
|
|
309
|
+
const at = i();
|
|
310
|
+
if (at?.priceRange) {
|
|
311
|
+
const At = r;
|
|
312
|
+
at.priceRange.minValue = At;
|
|
310
313
|
}
|
|
311
|
-
return
|
|
314
|
+
return at;
|
|
312
315
|
}
|
|
313
316
|
};
|
|
314
|
-
let
|
|
315
|
-
|
|
317
|
+
let B = w.current.get(n.label);
|
|
318
|
+
B ? (B.applyOptions(St), B.setData(
|
|
316
319
|
n.data.map((i) => ({
|
|
317
320
|
...i,
|
|
318
321
|
time: i.time
|
|
319
322
|
}))
|
|
320
|
-
)) : (
|
|
321
|
-
...
|
|
322
|
-
...
|
|
323
|
-
}),
|
|
323
|
+
)) : (B = t.addSeries($t, {
|
|
324
|
+
...Lt,
|
|
325
|
+
...St
|
|
326
|
+
}), B.setData(
|
|
324
327
|
n.data.map((i) => ({
|
|
325
328
|
...i,
|
|
326
329
|
time: i.time
|
|
327
330
|
}))
|
|
328
|
-
), w.current.set(n.label,
|
|
331
|
+
), w.current.set(n.label, B)), X++;
|
|
329
332
|
}
|
|
330
|
-
if (p &&
|
|
331
|
-
for (const o of
|
|
333
|
+
if (p && rt.length > 0)
|
|
334
|
+
for (const o of rt)
|
|
332
335
|
try {
|
|
333
336
|
const n = t.priceScale(o.priceScaleId);
|
|
334
337
|
n && n.applyOptions({
|
|
@@ -358,7 +361,7 @@ function ie({
|
|
|
358
361
|
try {
|
|
359
362
|
const o = t.priceScale("right");
|
|
360
363
|
o && o.applyOptions({
|
|
361
|
-
visible: !
|
|
364
|
+
visible: !y,
|
|
362
365
|
autoScale: !0,
|
|
363
366
|
scaleMargins: {
|
|
364
367
|
top: 0.1,
|
|
@@ -376,28 +379,28 @@ function ie({
|
|
|
376
379
|
});
|
|
377
380
|
} catch {
|
|
378
381
|
}
|
|
379
|
-
if (r !== void 0 && !
|
|
382
|
+
if (r !== void 0 && !y && (V || !p) && t.applyOptions({
|
|
380
383
|
handleScroll: {
|
|
381
384
|
vertTouchDrag: !1
|
|
382
385
|
}
|
|
383
|
-
}),
|
|
384
|
-
const o =
|
|
386
|
+
}), I.length > 0) {
|
|
387
|
+
const o = I.map((E) => Number(E.time)), n = Math.min(...o), H = Math.max(...o);
|
|
385
388
|
t.timeScale().setVisibleRange({ from: n, to: H });
|
|
386
389
|
}
|
|
387
390
|
gt.current && (gt.current = !1);
|
|
388
|
-
const
|
|
391
|
+
const nt = /* @__PURE__ */ new Map();
|
|
389
392
|
for (const o of e)
|
|
390
|
-
o.data.length > 0 &&
|
|
391
|
-
|
|
393
|
+
o.data.length > 0 && nt.set(o.label, o.data[o.data.length - 1]);
|
|
394
|
+
tt(nt.size > 0 ? nt : void 0);
|
|
392
395
|
}, [
|
|
393
396
|
e,
|
|
394
|
-
|
|
397
|
+
I,
|
|
395
398
|
f,
|
|
396
399
|
S,
|
|
397
|
-
V,
|
|
398
400
|
y,
|
|
399
|
-
|
|
400
|
-
ft
|
|
401
|
+
V,
|
|
402
|
+
ft,
|
|
403
|
+
dt
|
|
401
404
|
]), D(() => {
|
|
402
405
|
const t = k.current;
|
|
403
406
|
if (!t || e.length === 0) return;
|
|
@@ -410,18 +413,18 @@ function ie({
|
|
|
410
413
|
}
|
|
411
414
|
if (!r) return;
|
|
412
415
|
const l = (s) => {
|
|
413
|
-
const { time: c = r, seriesData: u, point: N } = s || {},
|
|
416
|
+
const { time: c = r, seriesData: u, point: N } = s || {}, d = Array.from(w.current.values());
|
|
414
417
|
if (!N || !c) {
|
|
415
418
|
const R = /* @__PURE__ */ new Map();
|
|
416
|
-
for (const
|
|
417
|
-
|
|
418
|
-
if (
|
|
419
|
-
|
|
420
|
-
else if (
|
|
419
|
+
for (const g of e)
|
|
420
|
+
g.data.length > 0 && R.set(g.label, g.data[g.data.length - 1]);
|
|
421
|
+
if (tt(R.size > 0 ? R : void 0), a || V)
|
|
422
|
+
z(null);
|
|
423
|
+
else if (d[0] && r) {
|
|
421
424
|
const x = t.timeScale().timeToCoordinate(r), b = e[0];
|
|
422
425
|
if (b.data.length > 0) {
|
|
423
|
-
const p = b.data[b.data.length - 1].value, T =
|
|
424
|
-
x !== null && T !== null &&
|
|
426
|
+
const p = b.data[b.data.length - 1].value, T = d[0].priceToCoordinate(p);
|
|
427
|
+
x !== null && T !== null && z({ x, y: T });
|
|
425
428
|
}
|
|
426
429
|
}
|
|
427
430
|
return;
|
|
@@ -429,54 +432,54 @@ function ie({
|
|
|
429
432
|
const P = /* @__PURE__ */ new Map();
|
|
430
433
|
let L;
|
|
431
434
|
for (let R = 0; R < e.length; R++) {
|
|
432
|
-
const
|
|
435
|
+
const g = e[R], x = d[R];
|
|
433
436
|
if (!x) continue;
|
|
434
|
-
const b = u?.get(x), p = b && "value" in b ? b.value : void 0, T =
|
|
435
|
-
R === 0 && (L = F), P.set(
|
|
437
|
+
const b = u?.get(x), p = b && "value" in b ? b.value : void 0, T = g.data[g.data.length - 1], F = p !== void 0 ? p : T?.value ?? 0;
|
|
438
|
+
R === 0 && (L = F), P.set(g.label, { value: F, time: c });
|
|
436
439
|
}
|
|
437
|
-
if (
|
|
438
|
-
const
|
|
439
|
-
if (
|
|
440
|
+
if (tt(P), L !== void 0 && d[0]) {
|
|
441
|
+
const g = t.timeScale().timeToCoordinate(c), x = d[0].priceToCoordinate(L);
|
|
442
|
+
if (g !== null && x !== null) {
|
|
440
443
|
const b = $.current;
|
|
441
444
|
if (b) {
|
|
442
445
|
const p = b.querySelector(
|
|
443
446
|
".LightweightChart"
|
|
444
447
|
);
|
|
445
448
|
if (p) {
|
|
446
|
-
const T = p.getBoundingClientRect(), F = b.getBoundingClientRect(),
|
|
447
|
-
|
|
449
|
+
const T = p.getBoundingClientRect(), F = b.getBoundingClientRect(), et = g + (T.left - F.left), ot = x + (T.top - F.top);
|
|
450
|
+
z({ x: et, y: ot });
|
|
448
451
|
} else
|
|
449
|
-
|
|
452
|
+
z({ x: g, y: x });
|
|
450
453
|
} else
|
|
451
|
-
|
|
454
|
+
z({ x: g, y: x });
|
|
452
455
|
} else
|
|
453
|
-
|
|
456
|
+
z(null);
|
|
454
457
|
} else
|
|
455
|
-
|
|
458
|
+
z(null);
|
|
456
459
|
};
|
|
457
|
-
return t.subscribeCrosshairMove(l),
|
|
460
|
+
return t.subscribeCrosshairMove(l), y && t.subscribeClick(l), !a && !V && requestAnimationFrame(() => {
|
|
458
461
|
const s = Array.from(w.current.values());
|
|
459
462
|
if (s[0] && r && e[0]?.data.length > 0) {
|
|
460
|
-
const u = t.timeScale().timeToCoordinate(r), N = e[0].data[e[0].data.length - 1].value,
|
|
461
|
-
u !== null &&
|
|
463
|
+
const u = t.timeScale().timeToCoordinate(r), N = e[0].data[e[0].data.length - 1].value, d = s[0].priceToCoordinate(N);
|
|
464
|
+
u !== null && d !== null && z({ x: u, y: d });
|
|
462
465
|
}
|
|
463
466
|
}), () => {
|
|
464
|
-
t.unsubscribeCrosshairMove(l),
|
|
467
|
+
t.unsubscribeCrosshairMove(l), y && t.unsubscribeClick(l);
|
|
465
468
|
};
|
|
466
|
-
}, [e,
|
|
469
|
+
}, [e, V, y]), D(() => {
|
|
467
470
|
const t = k.current;
|
|
468
471
|
if (!t || e.length === 0) return;
|
|
469
472
|
const a = t.timeScale(), r = () => {
|
|
470
|
-
if (!
|
|
473
|
+
if (!Q.current) return;
|
|
471
474
|
const l = a.getVisibleRange();
|
|
472
475
|
if (!l) return;
|
|
473
476
|
const s = Number(l.from), c = Number(l.to), u = [];
|
|
474
477
|
for (const N of e)
|
|
475
|
-
for (const
|
|
476
|
-
const P = Number(
|
|
477
|
-
P >= s && P <= c && u.push(
|
|
478
|
+
for (const d of N.data) {
|
|
479
|
+
const P = Number(d.time);
|
|
480
|
+
P >= s && P <= c && u.push(d.value);
|
|
478
481
|
}
|
|
479
|
-
u.length > 0 &&
|
|
482
|
+
u.length > 0 && Q.current(u);
|
|
480
483
|
};
|
|
481
484
|
return a.subscribeVisibleLogicalRangeChange(r), () => {
|
|
482
485
|
a.unsubscribeVisibleLogicalRangeChange(
|
|
@@ -486,9 +489,9 @@ function ie({
|
|
|
486
489
|
}, [e]), D(() => {
|
|
487
490
|
const t = k.current, a = Array.from(w.current.values()), r = [];
|
|
488
491
|
if (t && a.length > 0 && C) {
|
|
489
|
-
const l =
|
|
492
|
+
const l = Ot(), s = a[0];
|
|
490
493
|
for (const c of C) {
|
|
491
|
-
const u = new
|
|
494
|
+
const u = new jt(t, s, c.xCoordinate, {
|
|
492
495
|
...l,
|
|
493
496
|
...c.options || {}
|
|
494
497
|
});
|
|
@@ -505,12 +508,12 @@ function ie({
|
|
|
505
508
|
}, [C]), D(() => {
|
|
506
509
|
const t = k.current;
|
|
507
510
|
if (!t || !C?.length) {
|
|
508
|
-
|
|
511
|
+
pt([]);
|
|
509
512
|
return;
|
|
510
513
|
}
|
|
511
514
|
const a = () => {
|
|
512
515
|
const s = t.timeScale(), c = C.map((u) => s.timeToCoordinate(u.xCoordinate) ?? null);
|
|
513
|
-
|
|
516
|
+
pt(c);
|
|
514
517
|
};
|
|
515
518
|
a();
|
|
516
519
|
const r = t.timeScale(), l = () => {
|
|
@@ -520,59 +523,59 @@ function ie({
|
|
|
520
523
|
r.unsubscribeVisibleLogicalRangeChange(l);
|
|
521
524
|
};
|
|
522
525
|
}, [C]);
|
|
523
|
-
const
|
|
524
|
-
if (
|
|
526
|
+
const _ = e.length === 1, vt = lt.useMemo(() => {
|
|
527
|
+
if (_ && e.length > 0) {
|
|
525
528
|
const t = e[0];
|
|
526
529
|
if (t.data.length > 0)
|
|
527
530
|
return t.data[t.data.length - 1];
|
|
528
531
|
}
|
|
529
|
-
}, [
|
|
532
|
+
}, [_, e]);
|
|
530
533
|
return /* @__PURE__ */ j(
|
|
531
534
|
"div",
|
|
532
535
|
{
|
|
533
536
|
ref: $,
|
|
534
|
-
className:
|
|
537
|
+
className: ut(
|
|
535
538
|
"relative z-[1] w-full h-full overflow-hidden p-0",
|
|
536
539
|
v
|
|
537
540
|
),
|
|
538
541
|
children: [
|
|
539
|
-
|
|
540
|
-
|
|
542
|
+
K != null && K !== !1 && _ ? /* @__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: K }) }) : kt && _ && vt && /* @__PURE__ */ h(
|
|
543
|
+
Yt,
|
|
541
544
|
{
|
|
542
|
-
point:
|
|
545
|
+
point: vt,
|
|
543
546
|
xMeasureUnit: f,
|
|
544
547
|
yMeasureUnit: S,
|
|
545
|
-
decimals:
|
|
548
|
+
decimals: Z
|
|
546
549
|
}
|
|
547
550
|
),
|
|
548
|
-
|
|
549
|
-
|
|
551
|
+
mt && bt && /* @__PURE__ */ h(
|
|
552
|
+
Ht,
|
|
550
553
|
{
|
|
551
|
-
points:
|
|
554
|
+
points: mt,
|
|
552
555
|
xMeasureUnit: f,
|
|
553
556
|
yMeasureUnit: S,
|
|
554
557
|
series: e,
|
|
555
|
-
position:
|
|
558
|
+
position: bt,
|
|
556
559
|
containerRef: $,
|
|
557
|
-
decimals:
|
|
560
|
+
decimals: Z
|
|
558
561
|
}
|
|
559
562
|
),
|
|
560
|
-
m && /* @__PURE__ */ h(
|
|
561
|
-
C && C.length > 0 &&
|
|
563
|
+
m && /* @__PURE__ */ h(Xt, { series: e, onUnselect: A }),
|
|
564
|
+
C && C.length > 0 && ht.length === C.length && /* @__PURE__ */ h(
|
|
562
565
|
"div",
|
|
563
566
|
{
|
|
564
567
|
className: "absolute inset-0 z-[5] pointer-events-none",
|
|
565
568
|
"aria-hidden": !0,
|
|
566
569
|
children: C.map((t, a) => {
|
|
567
|
-
const r =
|
|
570
|
+
const r = ht[a], l = t.options ?? {}, s = l.showLabel !== !1;
|
|
568
571
|
if (r === null || !s) return null;
|
|
569
|
-
const { labelText: c, valueStr: u } =
|
|
572
|
+
const { labelText: c, valueStr: u } = Wt(
|
|
570
573
|
l,
|
|
571
574
|
S,
|
|
572
|
-
|
|
575
|
+
Z
|
|
573
576
|
);
|
|
574
577
|
if (!(c || u)) return null;
|
|
575
|
-
const
|
|
578
|
+
const d = l.labelBackgroundColor ?? l.color ?? "hsl(var(--background))", P = l.labelTextColor ?? "hsl(var(--foreground))", L = `${String(t.xCoordinate)}-${c}`;
|
|
576
579
|
return /* @__PURE__ */ j(
|
|
577
580
|
"div",
|
|
578
581
|
{
|
|
@@ -580,12 +583,12 @@ function ie({
|
|
|
580
583
|
style: {
|
|
581
584
|
left: r,
|
|
582
585
|
transform: "translateX(-50%)",
|
|
583
|
-
backgroundColor:
|
|
586
|
+
backgroundColor: d,
|
|
584
587
|
color: P
|
|
585
588
|
},
|
|
586
589
|
children: [
|
|
587
590
|
c && /* @__PURE__ */ h("span", { className: "block", children: c }),
|
|
588
|
-
u && /* @__PURE__ */ h("span", { className:
|
|
591
|
+
u && /* @__PURE__ */ h("span", { className: ut("block", c && "mt-0.5"), children: u })
|
|
589
592
|
]
|
|
590
593
|
},
|
|
591
594
|
L
|
|
@@ -596,7 +599,7 @@ function ie({
|
|
|
596
599
|
/* @__PURE__ */ h(
|
|
597
600
|
"div",
|
|
598
601
|
{
|
|
599
|
-
ref:
|
|
602
|
+
ref: U,
|
|
600
603
|
className: "LightweightChart w-full h-full overflow-hidden"
|
|
601
604
|
}
|
|
602
605
|
)
|
|
@@ -604,16 +607,16 @@ function ie({
|
|
|
604
607
|
}
|
|
605
608
|
);
|
|
606
609
|
}
|
|
607
|
-
function
|
|
610
|
+
function Xt({
|
|
608
611
|
series: e,
|
|
609
612
|
onUnselect: v
|
|
610
613
|
}) {
|
|
611
|
-
return /* @__PURE__ */ h("div", { className: "absolute top-0 left-2 z-[10] flex flex-wrap gap-2", children: e.map((m,
|
|
612
|
-
const f = Vt(
|
|
614
|
+
return /* @__PURE__ */ h("div", { className: "absolute top-0 left-2 z-[10] flex flex-wrap gap-2", children: e.map((m, A) => {
|
|
615
|
+
const f = Vt(A), S = (m.lineColor ?? m.color) || f.line, Y = m.data.length === 0;
|
|
613
616
|
return /* @__PURE__ */ j(
|
|
614
617
|
"div",
|
|
615
618
|
{
|
|
616
|
-
className:
|
|
619
|
+
className: ut(
|
|
617
620
|
"flex items-center gap-1.5 px-2 py-1 bg-background/80 backdrop-blur-sm rounded border border-border",
|
|
618
621
|
Y && "opacity-50"
|
|
619
622
|
),
|
|
@@ -668,8 +671,8 @@ function _t({
|
|
|
668
671
|
}) });
|
|
669
672
|
}
|
|
670
673
|
export {
|
|
671
|
-
|
|
672
|
-
|
|
674
|
+
ct as DEFAULT_SERIES_COLORS,
|
|
675
|
+
se as Graph,
|
|
673
676
|
Vt as getSeriesColorPalette,
|
|
674
|
-
|
|
677
|
+
Wt as getVerticalLineTooltipContent
|
|
675
678
|
};
|