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