@gearbox-protocol/ui-kit 3.14.0-next.33 → 3.14.0-next.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/assets-list-cell/assets-list-cell.cjs +1 -1
- package/dist/cjs/components/block-sync/block-sync.cjs +1 -1
- package/dist/cjs/components/block-sync-pill/block-sync-pill.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/composites/credit-account-history/body.cjs +1 -0
- package/dist/cjs/components/composites/credit-account-history/cells/details.cjs +1 -0
- package/dist/cjs/components/composites/credit-account-history/cells/hash.cjs +1 -0
- package/dist/cjs/components/composites/credit-account-history/cells/index.cjs +1 -0
- package/dist/cjs/components/composites/credit-account-history/cells/protocol.cjs +1 -0
- package/dist/cjs/components/composites/credit-account-history/cells/token-list.cjs +1 -0
- package/dist/cjs/components/composites/credit-account-history/credit-account-history.cjs +1 -0
- package/dist/cjs/components/composites/credit-account-history/index.cjs +1 -0
- package/dist/cjs/components/composites/credit-account-history/line.cjs +1 -0
- package/dist/cjs/components/composites/credit-account-history/types.cjs +1 -0
- package/dist/cjs/components/composites/index.cjs +1 -1
- package/dist/cjs/components/composites/pool-table/columns.cjs +1 -1
- package/dist/cjs/components/composites/tx-preview/confirm/amounts/TransactionConfirmAmountField.cjs +1 -1
- package/dist/cjs/components/composites/tx-preview/confirm/preview/OperationPreviewContent.cjs +1 -1
- package/dist/cjs/components/composites/tx-preview/operations/OperationsCard.cjs +1 -1
- package/dist/cjs/components/composites/tx-preview/operations/PoolDepositView.cjs +1 -1
- package/dist/cjs/components/composites/tx-preview/operations/PoolWithdrawView.cjs +1 -1
- package/dist/cjs/components/composites/tx-preview/state-change/BalanceChangeGroup.cjs +1 -1
- package/dist/cjs/components/composites/tx-preview/state-change/StateChangeCard.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/formatters.cjs +1 -1
- package/dist/cjs/components/graph/graph.cjs +1 -1
- package/dist/cjs/components/graph/index.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/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/trading-view/trading-view.cjs +1 -1
- package/dist/cjs/components/with-copy/with-copy.cjs +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/locale/en.json.cjs +1 -1
- package/dist/esm/components/assets-list-cell/assets-list-cell.js +3 -2
- package/dist/esm/components/block-sync/block-sync.js +3 -2
- package/dist/esm/components/block-sync-pill/block-sync-pill.js +3 -2
- package/dist/esm/components/checkbox/checkbox-labeled.js +1 -0
- package/dist/esm/components/client-adapters/styled-rounded-image/styled-rounded-image.js +1 -0
- package/dist/esm/components/complex-input/complex-input.js +3 -2
- package/dist/esm/components/composites/credit-account-history/body.js +73 -0
- package/dist/esm/components/composites/credit-account-history/cells/details.js +22 -0
- package/dist/esm/components/composites/credit-account-history/cells/hash.js +24 -0
- package/dist/esm/components/composites/credit-account-history/cells/index.js +10 -0
- package/dist/esm/components/composites/credit-account-history/cells/protocol.js +25 -0
- package/dist/esm/components/composites/credit-account-history/cells/token-list.js +43 -0
- package/dist/esm/components/composites/credit-account-history/credit-account-history.js +46 -0
- package/dist/esm/components/composites/credit-account-history/index.js +8 -0
- package/dist/esm/components/composites/credit-account-history/line.js +125 -0
- package/dist/esm/components/composites/credit-account-history/types.js +9 -0
- package/dist/esm/components/composites/index.js +85 -79
- package/dist/esm/components/composites/pool-table/columns.js +19 -18
- package/dist/esm/components/composites/tx-preview/confirm/amounts/TransactionConfirmAmountField.js +18 -17
- package/dist/esm/components/composites/tx-preview/confirm/preview/OperationPreviewContent.js +3 -2
- package/dist/esm/components/composites/tx-preview/operations/OperationsCard.js +3 -2
- package/dist/esm/components/composites/tx-preview/operations/PoolDepositView.js +3 -2
- package/dist/esm/components/composites/tx-preview/operations/PoolWithdrawView.js +3 -2
- package/dist/esm/components/composites/tx-preview/state-change/BalanceChangeGroup.js +3 -2
- package/dist/esm/components/composites/tx-preview/state-change/StateChangeCard.js +3 -2
- package/dist/esm/components/compound-apy/compound-apy.js +3 -2
- package/dist/esm/components/detailed-page-title/detailed-page-title.js +1 -0
- package/dist/esm/components/graph/formatters.js +48 -47
- package/dist/esm/components/graph/graph.js +491 -435
- package/dist/esm/components/graph/index.js +19 -18
- package/dist/esm/components/index.js +687 -680
- package/dist/esm/components/markdown-viewer/markdown-viewer.js +3 -2
- package/dist/esm/components/time-to-liquidation/time-to-liquidation.js +1 -0
- package/dist/esm/components/tokens-list-cell/tokens-list-cell.js +3 -2
- package/dist/esm/components/trading-view/trading-view.js +164 -147
- package/dist/esm/components/with-copy/with-copy.js +3 -2
- package/dist/esm/index.js +855 -848
- package/dist/esm/locale/en.json.js +3 -0
- package/dist/globals.css +1 -1
- package/dist/types/components/composites/credit-account-history/body.d.ts +14 -0
- package/dist/types/components/composites/credit-account-history/cells/details.d.ts +9 -0
- package/dist/types/components/composites/credit-account-history/cells/hash.d.ts +6 -0
- package/dist/types/components/composites/credit-account-history/cells/index.d.ts +4 -0
- package/dist/types/components/composites/credit-account-history/cells/protocol.d.ts +7 -0
- package/dist/types/components/composites/credit-account-history/cells/token-list.d.ts +9 -0
- package/dist/types/components/composites/credit-account-history/credit-account-history.d.ts +15 -0
- package/dist/types/components/composites/credit-account-history/index.d.ts +2 -0
- package/dist/types/components/composites/credit-account-history/line.d.ts +18 -0
- package/dist/types/components/composites/credit-account-history/types.d.ts +36 -0
- package/dist/types/components/composites/index.d.ts +1 -0
- package/dist/types/components/graph/graph.d.ts +40 -3
- package/dist/types/components/graph/index.d.ts +1 -1
- package/dist/types/components/trading-view/trading-view.d.ts +15 -1
- package/dist/types/locale/en.json.d.ts +4 -0
- package/package.json +2 -2
|
@@ -1,79 +1,79 @@
|
|
|
1
|
-
import { jsxs as
|
|
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
|
-
class
|
|
1
|
+
import { jsxs as te, jsx as y } from "react/jsx-runtime";
|
|
2
|
+
import { createChart as Ye, CrosshairMode as Ue, LineStyle as Ae, LineSeries as et, AreaSeries as tt } from "lightweight-charts";
|
|
3
|
+
import * as Ce from "react";
|
|
4
|
+
import { useRef as $, useState as Se, useEffect as F } from "react";
|
|
5
|
+
import { useIsMobile as ot } from "../../hooks/use-media-query.js";
|
|
6
|
+
import { cn as ae } from "../../utils/cn.js";
|
|
7
|
+
import { resolveCSSColor as ee, generateColorsFromBase as le, hslToHex as rt } from "../../utils/colors.js";
|
|
8
|
+
import { getDefaultOptions as $e, getDefaultSeries as nt, getDefaultVerticalLine as lt } from "./default-config.js";
|
|
9
|
+
import { getXFormatters as Ee, createAdaptiveYAxisFormatter as at, formatExactValue as xe } from "./formatters.js";
|
|
10
|
+
import { GraphCurrentValue as it } from "./graph-current-value.js";
|
|
11
|
+
import { GraphTooltip as st } from "./graph-tooltip.js";
|
|
12
|
+
import { VertLine as ct } from "./plugins/vertical-line.js";
|
|
13
|
+
class ut {
|
|
14
14
|
_yTop;
|
|
15
15
|
_yBottom;
|
|
16
16
|
_color;
|
|
17
|
-
constructor(
|
|
18
|
-
this._yTop =
|
|
17
|
+
constructor(s, f, m) {
|
|
18
|
+
this._yTop = s, this._yBottom = f, this._color = m;
|
|
19
19
|
}
|
|
20
|
-
draw(
|
|
21
|
-
|
|
22
|
-
const
|
|
23
|
-
|
|
20
|
+
draw(s) {
|
|
21
|
+
s.useBitmapCoordinateSpace((f) => {
|
|
22
|
+
const m = f.context, h = f.verticalPixelRatio, w = this._yTop === null ? 0 : this._yTop * h, X = this._yBottom === null ? f.bitmapSize.height : this._yBottom * h, b = Math.min(w, X), V = Math.max(w, X);
|
|
23
|
+
m.fillStyle = this._color, m.fillRect(0, b, f.bitmapSize.width, V - b);
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
-
class
|
|
27
|
+
class ft {
|
|
28
28
|
_source;
|
|
29
29
|
_yTop = null;
|
|
30
30
|
_yBottom = null;
|
|
31
|
-
constructor(
|
|
32
|
-
this._source =
|
|
31
|
+
constructor(s) {
|
|
32
|
+
this._source = s;
|
|
33
33
|
}
|
|
34
34
|
update() {
|
|
35
|
-
const
|
|
36
|
-
this._yTop = this._source.priceTop === void 0 ? null :
|
|
35
|
+
const s = this._source.series;
|
|
36
|
+
this._yTop = this._source.priceTop === void 0 ? null : s.priceToCoordinate(this._source.priceTop), this._yBottom = this._source.priceBottom === void 0 ? null : s.priceToCoordinate(this._source.priceBottom);
|
|
37
37
|
}
|
|
38
38
|
/** Draw beneath the series line/area so the data stays readable. */
|
|
39
39
|
zOrder() {
|
|
40
40
|
return "bottom";
|
|
41
41
|
}
|
|
42
42
|
renderer() {
|
|
43
|
-
return new
|
|
43
|
+
return new ut(this._yTop, this._yBottom, this._source.color);
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
|
-
class
|
|
46
|
+
class ht {
|
|
47
47
|
series;
|
|
48
48
|
priceTop;
|
|
49
49
|
priceBottom;
|
|
50
50
|
color;
|
|
51
51
|
_paneViews;
|
|
52
|
-
constructor(
|
|
53
|
-
this.series =
|
|
52
|
+
constructor(s, f, m, h) {
|
|
53
|
+
this.series = s, this.priceTop = f, this.priceBottom = m, this.color = h, this._paneViews = [new ft(this)];
|
|
54
54
|
}
|
|
55
55
|
updateAllViews() {
|
|
56
|
-
for (const
|
|
56
|
+
for (const s of this._paneViews) s.update();
|
|
57
57
|
}
|
|
58
58
|
paneViews() {
|
|
59
59
|
return this._paneViews;
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
|
-
function
|
|
63
|
-
const
|
|
62
|
+
function gt(t, s, f) {
|
|
63
|
+
const m = t.labelText ?? "", h = t.value, w = h === void 0 ? "" : typeof h == "number" ? s === "$" ? `$${xe(h, void 0, f)}` : s === "%" ? `${xe(h, void 0, f)}%` : xe(
|
|
64
64
|
h,
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
s !== "none" && s !== "%" && s !== "$" ? s : void 0,
|
|
66
|
+
f
|
|
67
67
|
) : String(h);
|
|
68
|
-
return { labelText:
|
|
68
|
+
return { labelText: m, valueStr: w };
|
|
69
69
|
}
|
|
70
|
-
function
|
|
71
|
-
for (let
|
|
72
|
-
if (Number(t[
|
|
73
|
-
return t[
|
|
70
|
+
function mt(t, s) {
|
|
71
|
+
for (let f = t.length - 1; f >= 0; f--)
|
|
72
|
+
if (Number(t[f].time) <= s)
|
|
73
|
+
return t[f].value;
|
|
74
74
|
return 0;
|
|
75
75
|
}
|
|
76
|
-
const
|
|
76
|
+
const ye = [
|
|
77
77
|
// 0 green (emerald)
|
|
78
78
|
{
|
|
79
79
|
line: "#02c39a",
|
|
@@ -188,67 +188,72 @@ const ve = [
|
|
|
188
188
|
top: "rgba(71, 85, 105, 0.56)",
|
|
189
189
|
bottom: "rgba(71, 85, 105, 0.04)"
|
|
190
190
|
}
|
|
191
|
-
],
|
|
192
|
-
function
|
|
193
|
-
if (t <
|
|
194
|
-
return
|
|
195
|
-
const
|
|
196
|
-
return { line:
|
|
191
|
+
], dt = 137.5;
|
|
192
|
+
function Ge(t) {
|
|
193
|
+
if (t < ye.length)
|
|
194
|
+
return ye[t];
|
|
195
|
+
const f = (t - ye.length) * dt % 360, m = rt(f, 70, 50), { topColor: h, bottomColor: w } = le(m);
|
|
196
|
+
return { line: m, top: h, bottom: w };
|
|
197
197
|
}
|
|
198
|
-
function
|
|
198
|
+
function Lt({
|
|
199
199
|
series: t,
|
|
200
|
-
className:
|
|
201
|
-
showLegend:
|
|
202
|
-
onUnselectSeries:
|
|
200
|
+
className: s,
|
|
201
|
+
showLegend: f = !1,
|
|
202
|
+
onUnselectSeries: m,
|
|
203
203
|
xMeasureUnit: h = "time",
|
|
204
|
-
yMeasureUnit:
|
|
205
|
-
optionsOverrides:
|
|
206
|
-
verticalLineOptions:
|
|
207
|
-
priceLineOptions:
|
|
208
|
-
zoneOptions:
|
|
209
|
-
currentValueDecimals:
|
|
210
|
-
useSharedPriceScale:
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
204
|
+
yMeasureUnit: w = "token",
|
|
205
|
+
optionsOverrides: X,
|
|
206
|
+
verticalLineOptions: b,
|
|
207
|
+
priceLineOptions: V,
|
|
208
|
+
zoneOptions: E,
|
|
209
|
+
currentValueDecimals: ie,
|
|
210
|
+
useSharedPriceScale: I = !1,
|
|
211
|
+
dualYAxis: L = !1,
|
|
212
|
+
defaultVisiblePriceScaleId: we = "right",
|
|
213
|
+
leftPriceScaleTitle: Te,
|
|
214
|
+
rightPriceScaleTitle: pt,
|
|
215
|
+
showCurrentValue: je = !0,
|
|
216
|
+
graphTitle: se,
|
|
217
|
+
yScaleMin: Ne,
|
|
218
|
+
yScaleMinMultiple: Ve,
|
|
219
|
+
visibleTimeFrom: q,
|
|
220
|
+
disableZoom: oe = !1,
|
|
221
|
+
hideDefaultTooltip: ce = !1
|
|
217
222
|
}) {
|
|
218
|
-
const
|
|
223
|
+
const k = $(null), p = $(/* @__PURE__ */ new Map()), ue = $(!1), Re = $(!0), fe = $(
|
|
219
224
|
null
|
|
220
|
-
),
|
|
225
|
+
), He = $(null), Z = $(null), he = $(null), re = $(null), T = ot(), G = Ce.useMemo(() => t.flatMap((e) => e.data), [t]), Xe = Ce.useMemo(() => {
|
|
221
226
|
if (t.length > 0) {
|
|
222
227
|
const e = t[t.length - 1];
|
|
223
228
|
if (e.data.length > 0)
|
|
224
229
|
return e.data[e.data.length - 1];
|
|
225
230
|
}
|
|
226
|
-
}, [t]), [
|
|
227
|
-
if (!
|
|
231
|
+
}, [t]), [Pe, ge] = Se(() => {
|
|
232
|
+
if (!Xe) return;
|
|
228
233
|
const e = /* @__PURE__ */ new Map();
|
|
229
|
-
for (const
|
|
230
|
-
|
|
234
|
+
for (const a of t)
|
|
235
|
+
a.data.length > 0 && e.set(a.label, a.data[a.data.length - 1]);
|
|
231
236
|
return e;
|
|
232
|
-
}), [
|
|
233
|
-
|
|
237
|
+
}), [Me, j] = Se(null), [_e, Le] = Se([]);
|
|
238
|
+
F(() => {
|
|
234
239
|
const e = () => {
|
|
235
240
|
try {
|
|
236
|
-
if (
|
|
237
|
-
const
|
|
238
|
-
|
|
241
|
+
if (k.current && Z.current) {
|
|
242
|
+
const n = Z.current.clientWidth, i = Z.current.clientHeight;
|
|
243
|
+
k.current.resize(n, i);
|
|
239
244
|
}
|
|
240
245
|
} catch {
|
|
241
246
|
}
|
|
242
|
-
},
|
|
243
|
-
return
|
|
244
|
-
|
|
247
|
+
}, a = Z.current, l = a ? new ResizeObserver(e) : null;
|
|
248
|
+
return re.current = l, a && l?.observe(a), () => {
|
|
249
|
+
a && l?.unobserve(a), l?.disconnect(), re.current = null;
|
|
245
250
|
};
|
|
246
|
-
}, []),
|
|
247
|
-
if (!
|
|
248
|
-
const e =
|
|
251
|
+
}, []), F(() => {
|
|
252
|
+
if (!he.current || ue.current) return;
|
|
253
|
+
const e = $e(), a = ee(
|
|
249
254
|
"hsl(var(--foreground))",
|
|
250
255
|
"rgb(0, 0, 0)"
|
|
251
|
-
),
|
|
256
|
+
), l = oe ? {
|
|
252
257
|
handleScale: {
|
|
253
258
|
mouseWheel: !1,
|
|
254
259
|
pinch: !1,
|
|
@@ -261,29 +266,34 @@ function Nt({
|
|
|
261
266
|
horzTouchDrag: !1,
|
|
262
267
|
vertTouchDrag: !1
|
|
263
268
|
}
|
|
264
|
-
} : {},
|
|
269
|
+
} : {}, n = Ye(he.current, {
|
|
265
270
|
...e,
|
|
271
|
+
leftPriceScale: {
|
|
272
|
+
...e.leftPriceScale || {},
|
|
273
|
+
visible: !1,
|
|
274
|
+
textColor: a
|
|
275
|
+
},
|
|
266
276
|
rightPriceScale: {
|
|
267
277
|
...e.rightPriceScale || {},
|
|
268
|
-
visible: !
|
|
269
|
-
textColor:
|
|
278
|
+
visible: !T,
|
|
279
|
+
textColor: a
|
|
270
280
|
},
|
|
271
|
-
...
|
|
281
|
+
...T && {
|
|
272
282
|
crosshair: {
|
|
273
283
|
...e.crosshair,
|
|
274
|
-
mode:
|
|
284
|
+
mode: Ue.Magnet
|
|
275
285
|
}
|
|
276
286
|
},
|
|
277
|
-
...
|
|
278
|
-
...
|
|
287
|
+
...l,
|
|
288
|
+
...X
|
|
279
289
|
});
|
|
280
|
-
return
|
|
281
|
-
|
|
290
|
+
return k.current = n, ue.current = !0, () => {
|
|
291
|
+
re.current?.disconnect(), re.current = null, n.remove(), k.current = null, ue.current = !1, p.current.clear();
|
|
282
292
|
};
|
|
283
|
-
}, [
|
|
284
|
-
const e =
|
|
293
|
+
}, [T, X, oe]), F(() => {
|
|
294
|
+
const e = k.current;
|
|
285
295
|
e && e.applyOptions(
|
|
286
|
-
|
|
296
|
+
oe ? {
|
|
287
297
|
handleScale: {
|
|
288
298
|
mouseWheel: !1,
|
|
289
299
|
pinch: !1,
|
|
@@ -311,47 +321,58 @@ function Nt({
|
|
|
311
321
|
}
|
|
312
322
|
}
|
|
313
323
|
);
|
|
314
|
-
}, [
|
|
315
|
-
const e =
|
|
324
|
+
}, [oe]), F(() => {
|
|
325
|
+
const e = k.current;
|
|
316
326
|
if (!e || t.length === 0) return;
|
|
317
|
-
const
|
|
318
|
-
formatter:
|
|
319
|
-
tickmarksFormatter:
|
|
320
|
-
updateVisibleRange:
|
|
321
|
-
updateLastValues:
|
|
322
|
-
} =
|
|
323
|
-
yScaleMin:
|
|
327
|
+
const l = t.filter((o) => o.data.length > 0).length <= 1 ? Ne : Ve, n = h === "time" ? Ee(h, G) : Ee(h), i = G.map((o) => o.value), {
|
|
328
|
+
formatter: c,
|
|
329
|
+
tickmarksFormatter: g,
|
|
330
|
+
updateVisibleRange: z,
|
|
331
|
+
updateLastValues: v
|
|
332
|
+
} = at(i, w, {
|
|
333
|
+
yScaleMin: l
|
|
324
334
|
});
|
|
325
|
-
|
|
326
|
-
const
|
|
327
|
-
|
|
328
|
-
const
|
|
335
|
+
fe.current = z, He.current = v;
|
|
336
|
+
const W = t.filter((o) => o.data.length > 0).map((o) => o.data[o.data.length - 1].value);
|
|
337
|
+
v(W);
|
|
338
|
+
const P = $e();
|
|
329
339
|
e.applyOptions({
|
|
330
340
|
localization: {
|
|
331
|
-
...
|
|
341
|
+
...P.localization || {},
|
|
332
342
|
// biome-ignore lint/suspicious/noExplicitAny: External library type compatibility
|
|
333
343
|
timeFormatter: (o) => (
|
|
334
344
|
// biome-ignore lint/suspicious/noExplicitAny: External library type compatibility
|
|
335
|
-
|
|
345
|
+
n.timeFormatter(parseFloat(o), void 0)
|
|
336
346
|
)
|
|
337
347
|
},
|
|
338
348
|
timeScale: {
|
|
339
|
-
...
|
|
349
|
+
...P.timeScale || {},
|
|
340
350
|
// biome-ignore lint/suspicious/noExplicitAny: External library type compatibility
|
|
341
|
-
tickMarkFormatter:
|
|
351
|
+
tickMarkFormatter: n.tickMarkFormatter,
|
|
342
352
|
minBarSpacing: 0
|
|
343
353
|
}
|
|
344
354
|
});
|
|
345
|
-
const
|
|
355
|
+
const d = (G.length > 0 ? Math.min(...G.map((o) => o.value)) : 0) < 0, R = G.some((o) => o.value === 0), C = !d && R, N = !L && t.length > 1 && !I, S = L ? T : t.length > 1 && !I || T, D = ee(
|
|
346
356
|
"hsl(var(--foreground))",
|
|
347
357
|
"rgb(0, 0, 0)"
|
|
348
358
|
);
|
|
349
359
|
e.applyOptions({
|
|
360
|
+
...L && {
|
|
361
|
+
defaultVisiblePriceScaleId: we
|
|
362
|
+
},
|
|
363
|
+
leftPriceScale: {
|
|
364
|
+
...P.leftPriceScale || {},
|
|
365
|
+
visible: L && !T,
|
|
366
|
+
textColor: D,
|
|
367
|
+
...L && Te && {
|
|
368
|
+
// lightweight-charts uses scale margins; title shown via localization if needed
|
|
369
|
+
}
|
|
370
|
+
},
|
|
350
371
|
rightPriceScale: {
|
|
351
|
-
...
|
|
352
|
-
visible: !
|
|
353
|
-
textColor:
|
|
354
|
-
...C && {
|
|
372
|
+
...P.rightPriceScale || {},
|
|
373
|
+
visible: L ? !T : !S,
|
|
374
|
+
textColor: D,
|
|
375
|
+
...C && !L && {
|
|
355
376
|
scaleMargins: {
|
|
356
377
|
top: 0.3,
|
|
357
378
|
bottom: 0
|
|
@@ -359,102 +380,123 @@ function Nt({
|
|
|
359
380
|
}
|
|
360
381
|
}
|
|
361
382
|
});
|
|
362
|
-
const
|
|
363
|
-
for (const o of
|
|
364
|
-
if (!
|
|
365
|
-
const
|
|
366
|
-
|
|
383
|
+
const Q = new Set(p.current.keys()), me = new Set(t.map((o) => o.label));
|
|
384
|
+
for (const o of Q)
|
|
385
|
+
if (!me.has(o)) {
|
|
386
|
+
const r = p.current.get(o);
|
|
387
|
+
r && (e.removeSeries(r), p.current.delete(o));
|
|
367
388
|
}
|
|
368
|
-
const
|
|
369
|
-
let
|
|
370
|
-
const
|
|
371
|
-
if (
|
|
372
|
-
for (const o of
|
|
389
|
+
const Be = nt(), de = [];
|
|
390
|
+
let Y = 0;
|
|
391
|
+
const De = t.find((o) => o.data.length > 0), U = /* @__PURE__ */ new Map();
|
|
392
|
+
if (V && V.length > 0)
|
|
393
|
+
for (const o of V) {
|
|
373
394
|
if (!Number.isFinite(o.price)) continue;
|
|
374
|
-
const
|
|
375
|
-
if (!
|
|
376
|
-
const
|
|
377
|
-
|
|
395
|
+
const r = o.seriesLabel ?? De?.label;
|
|
396
|
+
if (!r) continue;
|
|
397
|
+
const x = U.get(r) ?? [];
|
|
398
|
+
x.push(o.price), U.set(r, x);
|
|
378
399
|
}
|
|
379
|
-
if (
|
|
380
|
-
for (const o of
|
|
381
|
-
const
|
|
382
|
-
if (!
|
|
383
|
-
const
|
|
384
|
-
Number.isFinite(o.priceTop) &&
|
|
400
|
+
if (E && E.length > 0)
|
|
401
|
+
for (const o of E) {
|
|
402
|
+
const r = o.seriesLabel ?? De?.label;
|
|
403
|
+
if (!r) continue;
|
|
404
|
+
const x = U.get(r) ?? [];
|
|
405
|
+
Number.isFinite(o.priceTop) && x.push(o.priceTop), Number.isFinite(o.priceBottom) && x.push(o.priceBottom), U.set(r, x);
|
|
385
406
|
}
|
|
386
407
|
for (let o = 0; o < t.length; o++) {
|
|
387
|
-
const
|
|
388
|
-
let
|
|
389
|
-
if (
|
|
390
|
-
if (
|
|
391
|
-
|
|
392
|
-
else if (
|
|
393
|
-
const
|
|
394
|
-
|
|
395
|
-
} else if (
|
|
396
|
-
|
|
408
|
+
const r = t[o], x = Ge(o), K = r.lineColor ?? r.color ?? x.line;
|
|
409
|
+
let H, O;
|
|
410
|
+
if (r.lineColor ?? r.color)
|
|
411
|
+
if (r.topColor && r.bottomColor)
|
|
412
|
+
H = r.topColor, O = r.bottomColor;
|
|
413
|
+
else if (r.topColor) {
|
|
414
|
+
const u = le(K);
|
|
415
|
+
H = r.topColor, O = u.bottomColor;
|
|
416
|
+
} else if (r.bottomColor)
|
|
417
|
+
H = le(K).topColor, O = r.bottomColor;
|
|
397
418
|
else {
|
|
398
|
-
const
|
|
399
|
-
|
|
419
|
+
const u = le(K);
|
|
420
|
+
H = u.topColor, O = u.bottomColor;
|
|
400
421
|
}
|
|
401
422
|
else
|
|
402
|
-
|
|
403
|
-
if (
|
|
404
|
-
const
|
|
405
|
-
|
|
423
|
+
H = r.topColor || x.top, O = r.bottomColor || x.bottom;
|
|
424
|
+
if (r.data.length === 0) {
|
|
425
|
+
const u = p.current.get(r.label);
|
|
426
|
+
u && (e.removeSeries(u), p.current.delete(r.label));
|
|
406
427
|
continue;
|
|
407
428
|
}
|
|
408
|
-
const
|
|
409
|
-
|
|
410
|
-
priceScaleId:
|
|
411
|
-
shouldPreventNegativeAxis:
|
|
412
|
-
seriesIndex:
|
|
429
|
+
const qe = (r.data.length > 0 ? Math.min(...r.data.map((u) => u.value)) : 0) < 0, Ze = r.data.some((u) => u.value === 0), Ke = !qe && Ze, Fe = L ? r.priceScaleId ?? (Y === 0 ? "left" : "right") : I || !N || Y === 0 ? "right" : `scale-${Y}`;
|
|
430
|
+
N && de.push({
|
|
431
|
+
priceScaleId: Fe || "right",
|
|
432
|
+
shouldPreventNegativeAxis: Ke,
|
|
433
|
+
seriesIndex: Y
|
|
413
434
|
});
|
|
414
|
-
const
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
435
|
+
const Ie = (I || !N) && l !== void 0 && typeof l == "number", Oe = U.get(r.label) ?? [], Je = (u) => {
|
|
436
|
+
const _ = u();
|
|
437
|
+
if (_?.priceRange) {
|
|
438
|
+
Ie && (_.priceRange.minValue = l);
|
|
439
|
+
for (const A of Oe)
|
|
440
|
+
A < _.priceRange.minValue && (_.priceRange.minValue = A), A > _.priceRange.maxValue && (_.priceRange.maxValue = A);
|
|
441
|
+
}
|
|
442
|
+
return _;
|
|
443
|
+
}, pe = {
|
|
444
|
+
lineColor: K,
|
|
445
|
+
topColor: H,
|
|
446
|
+
bottomColor: O,
|
|
447
|
+
priceScaleId: Fe,
|
|
448
|
+
...r.seriesType === "line" && {
|
|
449
|
+
lineStyle: r.lineStyle ?? Ae.Solid
|
|
450
|
+
},
|
|
419
451
|
priceFormat: {
|
|
420
452
|
type: "custom",
|
|
421
453
|
minMove: 0.01,
|
|
422
|
-
formatter:
|
|
423
|
-
|
|
424
|
-
) :
|
|
425
|
-
tickmarksFormatter:
|
|
454
|
+
formatter: Ie && typeof l == "number" ? (u) => c(
|
|
455
|
+
u < l ? l : u
|
|
456
|
+
) : c,
|
|
457
|
+
tickmarksFormatter: g
|
|
426
458
|
},
|
|
427
|
-
autoscaleInfoProvider:
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
}
|
|
434
|
-
return k;
|
|
435
|
-
}
|
|
436
|
-
};
|
|
437
|
-
let Z = v.current.get(a.label);
|
|
438
|
-
const K = a.data.map((f) => ({
|
|
439
|
-
...f,
|
|
440
|
-
time: f.time
|
|
459
|
+
autoscaleInfoProvider: Je
|
|
460
|
+
}, ze = r.seriesType === "line";
|
|
461
|
+
let M = p.current.get(r.label);
|
|
462
|
+
const J = r.data.map((u) => ({
|
|
463
|
+
...u,
|
|
464
|
+
time: u.time
|
|
441
465
|
}));
|
|
442
|
-
if (
|
|
443
|
-
const
|
|
444
|
-
for (let
|
|
445
|
-
|
|
446
|
-
|
|
466
|
+
if (q !== void 0 && J.length > 0 && Number(J[0].time) > q) {
|
|
467
|
+
const u = Number(J[0].time), _ = u - q, A = 86400, Qe = _ > 180 * A ? 7 * A : _ > 30 * A ? A : 6 * 3600, We = [];
|
|
468
|
+
for (let ve = q; ve < u; ve += Qe)
|
|
469
|
+
We.push({ time: ve });
|
|
470
|
+
J.unshift(...We);
|
|
447
471
|
}
|
|
448
|
-
|
|
449
|
-
...
|
|
450
|
-
...
|
|
451
|
-
})
|
|
472
|
+
M && M.seriesType() !== (ze ? "Line" : "Area") && (e.removeSeries(M), p.current.delete(r.label), M = void 0), M ? (M.applyOptions(pe), M.setData(J)) : (ze ? M = e.addSeries(et, {
|
|
473
|
+
...Be,
|
|
474
|
+
...pe
|
|
475
|
+
}) : M = e.addSeries(tt, {
|
|
476
|
+
...Be,
|
|
477
|
+
...pe
|
|
478
|
+
}), M.setData(J), p.current.set(r.label, M)), Y++;
|
|
452
479
|
}
|
|
453
|
-
if (
|
|
454
|
-
|
|
480
|
+
if (L)
|
|
481
|
+
try {
|
|
482
|
+
const o = e.priceScale("left"), r = e.priceScale("right"), x = {
|
|
483
|
+
visible: !T,
|
|
484
|
+
autoScale: !0,
|
|
485
|
+
scaleMargins: { top: 0.1, bottom: 0.1 },
|
|
486
|
+
alignLabels: !0,
|
|
487
|
+
borderVisible: !0,
|
|
488
|
+
borderColor: "rgba(224, 227, 235, 0.1)",
|
|
489
|
+
entireTextOnly: !1,
|
|
490
|
+
textColor: D
|
|
491
|
+
};
|
|
492
|
+
o?.applyOptions(x), r?.applyOptions(x);
|
|
493
|
+
} catch {
|
|
494
|
+
}
|
|
495
|
+
else if (N && de.length > 0)
|
|
496
|
+
for (const o of de)
|
|
455
497
|
try {
|
|
456
|
-
const
|
|
457
|
-
|
|
498
|
+
const r = e.priceScale(o.priceScaleId);
|
|
499
|
+
r && r.applyOptions({
|
|
458
500
|
visible: !1,
|
|
459
501
|
autoScale: !0,
|
|
460
502
|
scaleMargins: {
|
|
@@ -469,24 +511,24 @@ function Nt({
|
|
|
469
511
|
borderVisible: !0,
|
|
470
512
|
borderColor: "rgba(224, 227, 235, 0.1)",
|
|
471
513
|
entireTextOnly: !1,
|
|
472
|
-
textColor:
|
|
514
|
+
textColor: D
|
|
473
515
|
});
|
|
474
|
-
} catch (
|
|
516
|
+
} catch (r) {
|
|
475
517
|
console.warn(
|
|
476
518
|
`Failed to configure price scale ${o.priceScaleId} for series ${o.seriesIndex}:`,
|
|
477
|
-
|
|
519
|
+
r
|
|
478
520
|
);
|
|
479
521
|
}
|
|
480
|
-
else if (!
|
|
522
|
+
else if (!N)
|
|
481
523
|
try {
|
|
482
524
|
const o = e.priceScale("right");
|
|
483
525
|
o && o.applyOptions({
|
|
484
|
-
visible: !
|
|
526
|
+
visible: !T,
|
|
485
527
|
autoScale: !0,
|
|
486
528
|
scaleMargins: {
|
|
487
529
|
top: 0.1,
|
|
488
530
|
// No bottom margin when yScaleMin is set so the scale doesn't extend below the minimum (avoids negative labels like -10M)
|
|
489
|
-
bottom:
|
|
531
|
+
bottom: l !== void 0 || C ? 0 : 0.1,
|
|
490
532
|
...C && {
|
|
491
533
|
top: 0.3
|
|
492
534
|
}
|
|
@@ -495,294 +537,297 @@ function Nt({
|
|
|
495
537
|
borderVisible: !0,
|
|
496
538
|
borderColor: "rgba(224, 227, 235, 0.1)",
|
|
497
539
|
entireTextOnly: !1,
|
|
498
|
-
textColor:
|
|
540
|
+
textColor: D
|
|
499
541
|
});
|
|
500
542
|
} catch {
|
|
501
543
|
}
|
|
502
|
-
if (
|
|
544
|
+
if (l !== void 0 && !T && (I || !N) && e.applyOptions({
|
|
503
545
|
handleScroll: {
|
|
504
546
|
vertTouchDrag: !1
|
|
505
547
|
}
|
|
506
|
-
}),
|
|
507
|
-
const o =
|
|
508
|
-
e.timeScale().setVisibleRange({ from:
|
|
548
|
+
}), G.length > 0) {
|
|
549
|
+
const o = G.map((H) => Number(H.time)), r = Math.min(...o), x = q !== void 0 ? Math.min(q, r) : r, K = Math.max(...o);
|
|
550
|
+
e.timeScale().setVisibleRange({ from: x, to: K });
|
|
509
551
|
}
|
|
510
|
-
|
|
511
|
-
const
|
|
552
|
+
Re.current && (Re.current = !1);
|
|
553
|
+
const be = /* @__PURE__ */ new Map();
|
|
512
554
|
for (const o of t)
|
|
513
|
-
o.data.length > 0 &&
|
|
514
|
-
|
|
555
|
+
o.data.length > 0 && be.set(o.label, o.data[o.data.length - 1]);
|
|
556
|
+
ge(be.size > 0 ? be : void 0);
|
|
515
557
|
}, [
|
|
516
558
|
t,
|
|
517
|
-
|
|
559
|
+
G,
|
|
518
560
|
h,
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
561
|
+
w,
|
|
562
|
+
T,
|
|
563
|
+
I,
|
|
564
|
+
L,
|
|
565
|
+
we,
|
|
566
|
+
Te,
|
|
567
|
+
Ne,
|
|
568
|
+
Ve,
|
|
569
|
+
q,
|
|
570
|
+
V,
|
|
571
|
+
E
|
|
572
|
+
]), F(() => {
|
|
573
|
+
const e = k.current;
|
|
529
574
|
if (!e || t.length === 0) return;
|
|
530
|
-
const
|
|
531
|
-
let
|
|
575
|
+
const a = t.length === 1;
|
|
576
|
+
let l;
|
|
532
577
|
for (const i of t)
|
|
533
578
|
if (i.data.length > 0) {
|
|
534
|
-
|
|
579
|
+
l = i.data[i.data.length - 1].time;
|
|
535
580
|
break;
|
|
536
581
|
}
|
|
537
|
-
if (!
|
|
538
|
-
const
|
|
539
|
-
const { time:
|
|
540
|
-
if (!
|
|
541
|
-
const
|
|
542
|
-
for (const
|
|
543
|
-
|
|
544
|
-
if (
|
|
545
|
-
|
|
546
|
-
else if (
|
|
547
|
-
const
|
|
582
|
+
if (!l) return;
|
|
583
|
+
const n = (i) => {
|
|
584
|
+
const { time: c = l, seriesData: g, point: z } = i || {}, v = Array.from(p.current.values());
|
|
585
|
+
if (!z || !c) {
|
|
586
|
+
const B = /* @__PURE__ */ new Map();
|
|
587
|
+
for (const d of t)
|
|
588
|
+
d.data.length > 0 && B.set(d.label, d.data[d.data.length - 1]);
|
|
589
|
+
if (ge(B.size > 0 ? B : void 0), a || I || ce)
|
|
590
|
+
j(null);
|
|
591
|
+
else if (v[0] && l) {
|
|
592
|
+
const R = e.timeScale().timeToCoordinate(l), C = t[0];
|
|
548
593
|
if (C.data.length > 0) {
|
|
549
|
-
const
|
|
550
|
-
|
|
594
|
+
const N = C.data[C.data.length - 1].value, S = v[0].priceToCoordinate(N);
|
|
595
|
+
R !== null && S !== null && j({ x: R, y: S });
|
|
551
596
|
}
|
|
552
597
|
}
|
|
553
598
|
return;
|
|
554
599
|
}
|
|
555
|
-
const
|
|
556
|
-
let
|
|
557
|
-
for (let
|
|
558
|
-
const
|
|
559
|
-
if (!
|
|
560
|
-
const C =
|
|
561
|
-
let
|
|
562
|
-
if (
|
|
563
|
-
|
|
564
|
-
else if (
|
|
565
|
-
const
|
|
566
|
-
|
|
600
|
+
const W = /* @__PURE__ */ new Map();
|
|
601
|
+
let P;
|
|
602
|
+
for (let B = 0; B < t.length; B++) {
|
|
603
|
+
const d = t[B], R = v[B];
|
|
604
|
+
if (!R) continue;
|
|
605
|
+
const C = g?.get(R), N = C && "value" in C ? C.value : void 0;
|
|
606
|
+
let S;
|
|
607
|
+
if (N !== void 0)
|
|
608
|
+
S = N;
|
|
609
|
+
else if (a) {
|
|
610
|
+
const D = Number(c), Q = d.data.length > 0 ? Number(d.data[0].time) : Number.POSITIVE_INFINITY;
|
|
611
|
+
D < Q ? S = Number.NaN : S = d.data[d.data.length - 1]?.value ?? 0;
|
|
567
612
|
} else
|
|
568
|
-
|
|
569
|
-
Number.isNaN(
|
|
613
|
+
S = mt(d.data, Number(c));
|
|
614
|
+
Number.isNaN(S) || (P === void 0 && (P = S), W.set(d.label, { value: S, time: c }));
|
|
570
615
|
}
|
|
571
|
-
if (
|
|
572
|
-
const
|
|
573
|
-
if (
|
|
574
|
-
const C =
|
|
616
|
+
if (ge(W), P !== void 0 && v[0]) {
|
|
617
|
+
const d = e.timeScale().timeToCoordinate(c), R = v[0].priceToCoordinate(P);
|
|
618
|
+
if (d !== null && R !== null) {
|
|
619
|
+
const C = Z.current;
|
|
575
620
|
if (C) {
|
|
576
|
-
const
|
|
621
|
+
const N = C.querySelector(
|
|
577
622
|
".LightweightChart"
|
|
578
623
|
);
|
|
579
|
-
if (
|
|
580
|
-
const
|
|
581
|
-
|
|
624
|
+
if (N) {
|
|
625
|
+
const S = N.getBoundingClientRect(), D = C.getBoundingClientRect(), Q = d + (S.left - D.left), me = R + (S.top - D.top);
|
|
626
|
+
j({ x: Q, y: me });
|
|
582
627
|
} else
|
|
583
|
-
|
|
628
|
+
j({ x: d, y: R });
|
|
584
629
|
} else
|
|
585
|
-
|
|
630
|
+
j({ x: d, y: R });
|
|
586
631
|
} else
|
|
587
|
-
|
|
632
|
+
j(null);
|
|
588
633
|
} else
|
|
589
|
-
|
|
634
|
+
j(null);
|
|
590
635
|
};
|
|
591
|
-
return e.subscribeCrosshairMove(
|
|
592
|
-
const i = Array.from(
|
|
593
|
-
if (i[0] &&
|
|
594
|
-
const
|
|
595
|
-
|
|
636
|
+
return e.subscribeCrosshairMove(n), T && e.subscribeClick(n), !a && !I && !ce && requestAnimationFrame(() => {
|
|
637
|
+
const i = Array.from(p.current.values());
|
|
638
|
+
if (i[0] && l && t[0]?.data.length > 0) {
|
|
639
|
+
const g = e.timeScale().timeToCoordinate(l), z = t[0].data[t[0].data.length - 1].value, v = i[0].priceToCoordinate(z);
|
|
640
|
+
g !== null && v !== null && j({ x: g, y: v });
|
|
596
641
|
}
|
|
597
642
|
}), () => {
|
|
598
|
-
e.unsubscribeCrosshairMove(
|
|
643
|
+
e.unsubscribeCrosshairMove(n), T && e.unsubscribeClick(n);
|
|
599
644
|
};
|
|
600
|
-
}, [t,
|
|
601
|
-
const e =
|
|
645
|
+
}, [t, I, T, ce]), F(() => {
|
|
646
|
+
const e = k.current;
|
|
602
647
|
if (!e || t.length === 0) return;
|
|
603
|
-
const
|
|
604
|
-
if (!
|
|
605
|
-
const
|
|
606
|
-
if (!
|
|
607
|
-
const i = Number(
|
|
608
|
-
for (const
|
|
609
|
-
for (const
|
|
610
|
-
const
|
|
611
|
-
|
|
648
|
+
const a = e.timeScale(), l = () => {
|
|
649
|
+
if (!fe.current) return;
|
|
650
|
+
const n = a.getVisibleRange();
|
|
651
|
+
if (!n) return;
|
|
652
|
+
const i = Number(n.from), c = Number(n.to), g = [];
|
|
653
|
+
for (const z of t)
|
|
654
|
+
for (const v of z.data) {
|
|
655
|
+
const W = Number(v.time);
|
|
656
|
+
W >= i && W <= c && g.push(v.value);
|
|
612
657
|
}
|
|
613
|
-
|
|
658
|
+
g.length > 0 && fe.current(g);
|
|
614
659
|
};
|
|
615
|
-
return
|
|
616
|
-
|
|
617
|
-
|
|
660
|
+
return a.subscribeVisibleLogicalRangeChange(l), () => {
|
|
661
|
+
a.unsubscribeVisibleLogicalRangeChange(
|
|
662
|
+
l
|
|
618
663
|
);
|
|
619
664
|
};
|
|
620
|
-
}, [t]),
|
|
621
|
-
const e =
|
|
622
|
-
if (e &&
|
|
623
|
-
const
|
|
624
|
-
for (const
|
|
625
|
-
const
|
|
626
|
-
...
|
|
627
|
-
...
|
|
665
|
+
}, [t]), F(() => {
|
|
666
|
+
const e = k.current, a = Array.from(p.current.values()), l = [];
|
|
667
|
+
if (e && a.length > 0 && b) {
|
|
668
|
+
const n = lt(), i = a[0];
|
|
669
|
+
for (const c of b) {
|
|
670
|
+
const g = new ct(e, i, c.xCoordinate, {
|
|
671
|
+
...n,
|
|
672
|
+
...c.options || {}
|
|
628
673
|
});
|
|
629
|
-
i.attachPrimitive(
|
|
674
|
+
i.attachPrimitive(g), l.push(g);
|
|
630
675
|
}
|
|
631
676
|
}
|
|
632
677
|
return () => {
|
|
633
|
-
if (
|
|
634
|
-
const
|
|
635
|
-
for (const i of
|
|
636
|
-
|
|
678
|
+
if (a.length > 0) {
|
|
679
|
+
const n = a[0];
|
|
680
|
+
for (const i of l)
|
|
681
|
+
n.detachPrimitive(i);
|
|
637
682
|
}
|
|
638
683
|
};
|
|
639
|
-
}, [
|
|
684
|
+
}, [b, t]), F(() => {
|
|
640
685
|
const e = [];
|
|
641
|
-
if (
|
|
642
|
-
const
|
|
686
|
+
if (V && V.length > 0) {
|
|
687
|
+
const a = Array.from(p.current.values())[0], l = ee(
|
|
643
688
|
"hsl(var(--destructive))",
|
|
644
689
|
"rgb(239, 68, 68)"
|
|
645
690
|
);
|
|
646
|
-
for (const
|
|
647
|
-
if (!Number.isFinite(
|
|
648
|
-
const i =
|
|
691
|
+
for (const n of V) {
|
|
692
|
+
if (!Number.isFinite(n.price)) continue;
|
|
693
|
+
const i = n.seriesLabel ? p.current.get(n.seriesLabel) : a;
|
|
649
694
|
if (!i) continue;
|
|
650
|
-
const
|
|
651
|
-
price:
|
|
652
|
-
color:
|
|
653
|
-
lineWidth:
|
|
654
|
-
lineStyle:
|
|
655
|
-
axisLabelVisible:
|
|
656
|
-
title:
|
|
695
|
+
const c = i.createPriceLine({
|
|
696
|
+
price: n.price,
|
|
697
|
+
color: n.color ? ee(n.color, n.color) : l,
|
|
698
|
+
lineWidth: n.lineWidth ?? 1,
|
|
699
|
+
lineStyle: n.lineStyle ?? Ae.Dashed,
|
|
700
|
+
axisLabelVisible: n.axisLabelVisible ?? !0,
|
|
701
|
+
title: n.title ?? ""
|
|
657
702
|
});
|
|
658
|
-
e.push({ series: i, line:
|
|
703
|
+
e.push({ series: i, line: c });
|
|
659
704
|
}
|
|
660
705
|
}
|
|
661
706
|
return () => {
|
|
662
|
-
for (const { series:
|
|
707
|
+
for (const { series: a, line: l } of e)
|
|
663
708
|
try {
|
|
664
|
-
|
|
709
|
+
a.removePriceLine(l);
|
|
665
710
|
} catch {
|
|
666
711
|
}
|
|
667
712
|
};
|
|
668
|
-
}, [
|
|
713
|
+
}, [V, t]), F(() => {
|
|
669
714
|
const e = [];
|
|
670
|
-
if (
|
|
671
|
-
const
|
|
672
|
-
for (const
|
|
673
|
-
const i =
|
|
715
|
+
if (E && E.length > 0) {
|
|
716
|
+
const a = Array.from(p.current.values())[0], l = "rgba(239, 68, 68, 0.12)";
|
|
717
|
+
for (const n of E) {
|
|
718
|
+
const i = n.seriesLabel ? p.current.get(n.seriesLabel) : a;
|
|
674
719
|
if (!i) continue;
|
|
675
|
-
const
|
|
720
|
+
const c = n.color ? ee(n.color, l) : l, g = new ht(
|
|
676
721
|
i,
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
722
|
+
n.priceTop,
|
|
723
|
+
n.priceBottom,
|
|
724
|
+
c
|
|
680
725
|
);
|
|
681
|
-
i.attachPrimitive(
|
|
726
|
+
i.attachPrimitive(g), e.push({ series: i, zone: g });
|
|
682
727
|
}
|
|
683
728
|
}
|
|
684
729
|
return () => {
|
|
685
|
-
for (const { series:
|
|
730
|
+
for (const { series: a, zone: l } of e)
|
|
686
731
|
try {
|
|
687
|
-
|
|
732
|
+
a.detachPrimitive(l);
|
|
688
733
|
} catch {
|
|
689
734
|
}
|
|
690
735
|
};
|
|
691
|
-
}, [
|
|
692
|
-
const e =
|
|
693
|
-
if (!e || !
|
|
694
|
-
|
|
736
|
+
}, [E, t]), F(() => {
|
|
737
|
+
const e = k.current;
|
|
738
|
+
if (!e || !b?.length) {
|
|
739
|
+
Le([]);
|
|
695
740
|
return;
|
|
696
741
|
}
|
|
697
|
-
const
|
|
698
|
-
const i = e.timeScale(),
|
|
699
|
-
|
|
742
|
+
const a = () => {
|
|
743
|
+
const i = e.timeScale(), c = b.map((g) => i.timeToCoordinate(g.xCoordinate) ?? null);
|
|
744
|
+
Le(c);
|
|
700
745
|
};
|
|
701
|
-
|
|
702
|
-
const
|
|
703
|
-
|
|
746
|
+
a();
|
|
747
|
+
const l = e.timeScale(), n = () => {
|
|
748
|
+
a();
|
|
704
749
|
};
|
|
705
|
-
return
|
|
706
|
-
|
|
750
|
+
return l.subscribeVisibleLogicalRangeChange(n), () => {
|
|
751
|
+
l.unsubscribeVisibleLogicalRangeChange(n);
|
|
707
752
|
};
|
|
708
|
-
}, [
|
|
709
|
-
const
|
|
710
|
-
if (
|
|
753
|
+
}, [b, t]);
|
|
754
|
+
const ne = t.length === 1, ke = Ce.useMemo(() => {
|
|
755
|
+
if (ne && t.length > 0) {
|
|
711
756
|
const e = t[0];
|
|
712
757
|
if (e.data.length > 0)
|
|
713
758
|
return e.data[e.data.length - 1];
|
|
714
759
|
}
|
|
715
|
-
}, [
|
|
716
|
-
return /* @__PURE__ */
|
|
760
|
+
}, [ne, t]);
|
|
761
|
+
return /* @__PURE__ */ te(
|
|
717
762
|
"div",
|
|
718
763
|
{
|
|
719
|
-
ref:
|
|
720
|
-
className:
|
|
764
|
+
ref: Z,
|
|
765
|
+
className: ae(
|
|
721
766
|
"relative z-[1] w-full h-full overflow-hidden p-0",
|
|
722
|
-
|
|
767
|
+
s
|
|
723
768
|
),
|
|
724
769
|
children: [
|
|
725
|
-
|
|
726
|
-
|
|
770
|
+
se != null && se !== !1 && ne ? /* @__PURE__ */ y("div", { className: "absolute top-2 left-2 right-2 z-[100] pointer-events-none", children: /* @__PURE__ */ y("div", { className: "text-xl sm:text-2xl font-semibold text-foreground whitespace-nowrap overflow-hidden text-ellipsis", children: se }) }) : je && ne && ke && /* @__PURE__ */ y(
|
|
771
|
+
it,
|
|
727
772
|
{
|
|
728
|
-
point:
|
|
773
|
+
point: ke,
|
|
729
774
|
xMeasureUnit: h,
|
|
730
|
-
yMeasureUnit:
|
|
731
|
-
decimals:
|
|
775
|
+
yMeasureUnit: w,
|
|
776
|
+
decimals: ie
|
|
732
777
|
}
|
|
733
778
|
),
|
|
734
|
-
|
|
735
|
-
|
|
779
|
+
Pe && Me && /* @__PURE__ */ y(
|
|
780
|
+
st,
|
|
736
781
|
{
|
|
737
|
-
points:
|
|
782
|
+
points: Pe,
|
|
738
783
|
xMeasureUnit: h,
|
|
739
|
-
yMeasureUnit:
|
|
784
|
+
yMeasureUnit: w,
|
|
740
785
|
series: t,
|
|
741
|
-
position:
|
|
742
|
-
containerRef:
|
|
743
|
-
decimals:
|
|
786
|
+
position: Me,
|
|
787
|
+
containerRef: Z,
|
|
788
|
+
decimals: ie
|
|
744
789
|
}
|
|
745
790
|
),
|
|
746
|
-
|
|
747
|
-
|
|
791
|
+
f && /* @__PURE__ */ y(bt, { series: t, onUnselect: m }),
|
|
792
|
+
b && b.length > 0 && _e.length === b.length && /* @__PURE__ */ y(
|
|
748
793
|
"div",
|
|
749
794
|
{
|
|
750
795
|
className: "absolute inset-0 z-[5] pointer-events-none",
|
|
751
796
|
"aria-hidden": !0,
|
|
752
|
-
children:
|
|
753
|
-
const
|
|
754
|
-
if (
|
|
755
|
-
const { labelText:
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
797
|
+
children: b.map((e, a) => {
|
|
798
|
+
const l = _e[a], n = e.options ?? {}, i = n.showLabel !== !1;
|
|
799
|
+
if (l === null || !i) return null;
|
|
800
|
+
const { labelText: c, valueStr: g } = gt(
|
|
801
|
+
n,
|
|
802
|
+
w,
|
|
803
|
+
ie
|
|
759
804
|
);
|
|
760
|
-
if (!(
|
|
761
|
-
const
|
|
762
|
-
return /* @__PURE__ */
|
|
805
|
+
if (!(c || g)) return null;
|
|
806
|
+
const v = n.labelBackgroundColor ?? n.color ?? "hsl(var(--background))", W = n.labelTextColor ?? "hsl(var(--foreground))", P = `${String(e.xCoordinate)}-${c}`;
|
|
807
|
+
return /* @__PURE__ */ te(
|
|
763
808
|
"div",
|
|
764
809
|
{
|
|
765
810
|
className: "absolute top-2 px-2 py-1 rounded text-xs font-medium whitespace-nowrap shadow-sm border border-border",
|
|
766
811
|
style: {
|
|
767
|
-
left:
|
|
812
|
+
left: l,
|
|
768
813
|
transform: "translateX(-50%)",
|
|
769
|
-
backgroundColor:
|
|
770
|
-
color:
|
|
814
|
+
backgroundColor: v,
|
|
815
|
+
color: W
|
|
771
816
|
},
|
|
772
817
|
children: [
|
|
773
|
-
|
|
774
|
-
|
|
818
|
+
c && /* @__PURE__ */ y("span", { className: "block", children: c }),
|
|
819
|
+
g && /* @__PURE__ */ y("span", { className: ae("block", c && "mt-0.5"), children: g })
|
|
775
820
|
]
|
|
776
821
|
},
|
|
777
|
-
|
|
822
|
+
P
|
|
778
823
|
);
|
|
779
824
|
})
|
|
780
825
|
}
|
|
781
826
|
),
|
|
782
|
-
/* @__PURE__ */
|
|
827
|
+
/* @__PURE__ */ y(
|
|
783
828
|
"div",
|
|
784
829
|
{
|
|
785
|
-
ref:
|
|
830
|
+
ref: he,
|
|
786
831
|
className: "LightweightChart w-full h-full overflow-hidden"
|
|
787
832
|
}
|
|
788
833
|
)
|
|
@@ -790,73 +835,84 @@ function Nt({
|
|
|
790
835
|
}
|
|
791
836
|
);
|
|
792
837
|
}
|
|
793
|
-
function
|
|
838
|
+
function bt({
|
|
794
839
|
series: t,
|
|
795
|
-
onUnselect:
|
|
840
|
+
onUnselect: s,
|
|
841
|
+
inline: f = !1
|
|
796
842
|
}) {
|
|
797
|
-
return /* @__PURE__ */
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
),
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
z && " (no data)"
|
|
817
|
-
] }),
|
|
818
|
-
c && /* @__PURE__ */ S(
|
|
819
|
-
"button",
|
|
820
|
-
{
|
|
821
|
-
type: "button",
|
|
822
|
-
onClick: (p) => {
|
|
823
|
-
p.stopPropagation(), c(s.label);
|
|
824
|
-
},
|
|
825
|
-
className: "ml-1 flex items-center justify-center w-4 h-4 rounded-sm hover:bg-muted transition-colors cursor-pointer",
|
|
826
|
-
"aria-label": `Remove ${s.label}`,
|
|
827
|
-
children: /* @__PURE__ */ U(
|
|
828
|
-
"svg",
|
|
843
|
+
return /* @__PURE__ */ y(
|
|
844
|
+
"div",
|
|
845
|
+
{
|
|
846
|
+
className: ae(
|
|
847
|
+
"flex flex-wrap gap-2",
|
|
848
|
+
f ? "items-center" : "absolute top-0 left-2 z-[10]"
|
|
849
|
+
),
|
|
850
|
+
children: t.map((m, h) => {
|
|
851
|
+
const w = Ge(h), X = (m.lineColor ?? m.color) || w.line, b = m.data.length === 0;
|
|
852
|
+
return /* @__PURE__ */ te(
|
|
853
|
+
"div",
|
|
854
|
+
{
|
|
855
|
+
className: ae(
|
|
856
|
+
"flex items-center gap-1.5 px-2 py-1 bg-background/80 backdrop-blur-sm rounded border border-border",
|
|
857
|
+
b && "opacity-50"
|
|
858
|
+
),
|
|
859
|
+
children: [
|
|
860
|
+
/* @__PURE__ */ y(
|
|
861
|
+
"div",
|
|
829
862
|
{
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
863
|
+
className: "w-3 h-3 rounded-sm",
|
|
864
|
+
style: { backgroundColor: X }
|
|
865
|
+
}
|
|
866
|
+
),
|
|
867
|
+
/* @__PURE__ */ te("span", { className: "text-[10px] sm:text-xs font-medium text-foreground", children: [
|
|
868
|
+
m.label,
|
|
869
|
+
b && " (no data)"
|
|
870
|
+
] }),
|
|
871
|
+
s && /* @__PURE__ */ y(
|
|
872
|
+
"button",
|
|
873
|
+
{
|
|
874
|
+
type: "button",
|
|
875
|
+
onClick: (V) => {
|
|
876
|
+
V.stopPropagation(), s(m.label);
|
|
877
|
+
},
|
|
878
|
+
className: "ml-1 flex items-center justify-center w-4 h-4 rounded-sm hover:bg-muted transition-colors cursor-pointer",
|
|
879
|
+
"aria-label": `Remove ${m.label}`,
|
|
880
|
+
children: /* @__PURE__ */ te(
|
|
881
|
+
"svg",
|
|
882
|
+
{
|
|
883
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
884
|
+
width: "12",
|
|
885
|
+
height: "12",
|
|
886
|
+
viewBox: "0 0 24 24",
|
|
887
|
+
fill: "none",
|
|
888
|
+
stroke: "currentColor",
|
|
889
|
+
strokeWidth: "2",
|
|
890
|
+
strokeLinecap: "round",
|
|
891
|
+
strokeLinejoin: "round",
|
|
892
|
+
className: "text-muted-foreground hover:text-foreground",
|
|
893
|
+
"aria-hidden": "true",
|
|
894
|
+
children: [
|
|
895
|
+
/* @__PURE__ */ y("title", { children: "Close" }),
|
|
896
|
+
/* @__PURE__ */ y("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
|
|
897
|
+
/* @__PURE__ */ y("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
|
|
898
|
+
]
|
|
899
|
+
}
|
|
900
|
+
)
|
|
846
901
|
}
|
|
847
902
|
)
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
903
|
+
]
|
|
904
|
+
},
|
|
905
|
+
m.label
|
|
906
|
+
);
|
|
907
|
+
})
|
|
908
|
+
}
|
|
909
|
+
);
|
|
855
910
|
}
|
|
856
911
|
export {
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
912
|
+
ye as DEFAULT_SERIES_COLORS,
|
|
913
|
+
Lt as Graph,
|
|
914
|
+
bt as GraphLegend,
|
|
915
|
+
Ge as getSeriesColorPalette,
|
|
916
|
+
mt as getStepForwardValue,
|
|
917
|
+
gt as getVerticalLineTooltipContent
|
|
862
918
|
};
|