@gearbox-protocol/permissionless-ui 1.26.2 → 1.26.3
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/graph/formatters.cjs +1 -1
- package/dist/cjs/components/graph/graph-tooltip.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/trading-view/trading-view.cjs +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/esm/components/graph/formatters.js +147 -105
- package/dist/esm/components/graph/graph-tooltip.js +8 -8
- package/dist/esm/components/graph/graph.js +341 -302
- package/dist/esm/components/graph/index.js +16 -15
- package/dist/esm/components/index.js +440 -439
- package/dist/esm/components/trading-view/trading-view.js +147 -143
- package/dist/esm/index.js +589 -588
- package/dist/types/components/graph/formatters.d.ts +10 -1
- package/dist/types/components/graph/index.d.ts +1 -1
- package/dist/types/components/graph/plugins/vertical-line.d.ts +2 -2
- package/dist/types/components/trading-view/trading-view.d.ts +2 -0
- package/package.json +6 -6
|
@@ -1,225 +1,250 @@
|
|
|
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 Vt, generateColorsFromBase as
|
|
8
|
-
import { getDefaultOptions as yt, getDefaultSeries as
|
|
9
|
-
import {
|
|
10
|
-
import { GraphCurrentValue as
|
|
11
|
-
import { GraphTooltip as
|
|
12
|
-
import { VertLine as
|
|
13
|
-
function
|
|
14
|
-
const A =
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
) : String(
|
|
19
|
-
return { labelText: A, valueStr:
|
|
1
|
+
import { jsxs as j, jsx as p } from "react/jsx-runtime";
|
|
2
|
+
import { createChart as Gt, CrosshairMode as Ot, AreaSeries as Bt } from "lightweight-charts";
|
|
3
|
+
import * as ct from "react";
|
|
4
|
+
import { useRef as P, useState as ut, useEffect as $ } from "react";
|
|
5
|
+
import { useIsMobile as Yt } from "../../hooks/use-media-query.js";
|
|
6
|
+
import { cn as dt } from "../../utils/cn.js";
|
|
7
|
+
import { resolveCSSColor as Vt, generateColorsFromBase as q, hslToHex as jt } from "../../utils/colors.js";
|
|
8
|
+
import { getDefaultOptions as yt, getDefaultSeries as Ht, getDefaultVerticalLine as Wt } from "./default-config.js";
|
|
9
|
+
import { getXFormatters as kt, createAdaptiveYAxisFormatter as _t, formatExactValue as ft } from "./formatters.js";
|
|
10
|
+
import { GraphCurrentValue as Xt } from "./graph-current-value.js";
|
|
11
|
+
import { GraphTooltip as Lt } from "./graph-tooltip.js";
|
|
12
|
+
import { VertLine as qt } from "./plugins/vertical-line.js";
|
|
13
|
+
function Zt(e, S, C) {
|
|
14
|
+
const A = e.labelText ?? "", f = e.value, w = f === void 0 ? "" : typeof f == "number" ? S === "$" ? `$${ft(f, void 0, C)}` : S === "%" ? `${ft(f, void 0, C)}%` : ft(
|
|
15
|
+
f,
|
|
16
|
+
S !== "none" && S !== "%" && S !== "$" ? S : void 0,
|
|
17
|
+
C
|
|
18
|
+
) : String(f);
|
|
19
|
+
return { labelText: A, valueStr: w };
|
|
20
20
|
}
|
|
21
|
-
const
|
|
21
|
+
const gt = [
|
|
22
|
+
// 0 green (emerald)
|
|
22
23
|
{
|
|
23
24
|
line: "#02c39a",
|
|
24
25
|
top: "rgba(2, 195, 154, 0.56)",
|
|
25
26
|
bottom: "rgba(2, 195, 154, 0.04)"
|
|
26
27
|
},
|
|
28
|
+
// 1 blue
|
|
27
29
|
{
|
|
28
30
|
line: "#3b82f6",
|
|
29
31
|
top: "rgba(59, 130, 246, 0.56)",
|
|
30
32
|
bottom: "rgba(59, 130, 246, 0.04)"
|
|
31
33
|
},
|
|
34
|
+
// 2 red
|
|
32
35
|
{
|
|
33
36
|
line: "#ef4444",
|
|
34
37
|
top: "rgba(239, 68, 68, 0.56)",
|
|
35
38
|
bottom: "rgba(239, 68, 68, 0.04)"
|
|
36
39
|
},
|
|
40
|
+
// 3 amber
|
|
37
41
|
{
|
|
38
42
|
line: "#f59e0b",
|
|
39
43
|
top: "rgba(245, 158, 11, 0.56)",
|
|
40
44
|
bottom: "rgba(245, 158, 11, 0.04)"
|
|
41
45
|
},
|
|
46
|
+
// 4 violet
|
|
42
47
|
{
|
|
43
48
|
line: "#8b5cf6",
|
|
44
49
|
top: "rgba(139, 92, 246, 0.56)",
|
|
45
50
|
bottom: "rgba(139, 92, 246, 0.04)"
|
|
46
51
|
},
|
|
52
|
+
// 5 pink
|
|
47
53
|
{
|
|
48
54
|
line: "#ec4899",
|
|
49
55
|
top: "rgba(236, 72, 153, 0.56)",
|
|
50
56
|
bottom: "rgba(236, 72, 153, 0.04)"
|
|
51
57
|
},
|
|
58
|
+
// 6 cyan
|
|
52
59
|
{
|
|
53
60
|
line: "#06b6d4",
|
|
54
61
|
top: "rgba(6, 182, 212, 0.56)",
|
|
55
62
|
bottom: "rgba(6, 182, 212, 0.04)"
|
|
56
63
|
},
|
|
64
|
+
// 7 orange
|
|
57
65
|
{
|
|
58
|
-
line: "#
|
|
59
|
-
top: "rgba(
|
|
60
|
-
bottom: "rgba(
|
|
66
|
+
line: "#ea580c",
|
|
67
|
+
top: "rgba(234, 88, 12, 0.56)",
|
|
68
|
+
bottom: "rgba(234, 88, 12, 0.04)"
|
|
61
69
|
},
|
|
70
|
+
// 8 lime
|
|
62
71
|
{
|
|
63
|
-
line: "#
|
|
64
|
-
top: "rgba(
|
|
65
|
-
bottom: "rgba(
|
|
72
|
+
line: "#84cc16",
|
|
73
|
+
top: "rgba(132, 204, 22, 0.56)",
|
|
74
|
+
bottom: "rgba(132, 204, 22, 0.04)"
|
|
66
75
|
},
|
|
76
|
+
// 9 fuchsia
|
|
67
77
|
{
|
|
68
78
|
line: "#d946ef",
|
|
69
79
|
top: "rgba(217, 70, 239, 0.56)",
|
|
70
80
|
bottom: "rgba(217, 70, 239, 0.04)"
|
|
71
81
|
},
|
|
82
|
+
// 10 sky
|
|
72
83
|
{
|
|
73
|
-
line: "#
|
|
74
|
-
top: "rgba(
|
|
75
|
-
bottom: "rgba(
|
|
76
|
-
},
|
|
77
|
-
{
|
|
78
|
-
line: "#ea580c",
|
|
79
|
-
top: "rgba(234, 88, 12, 0.56)",
|
|
80
|
-
bottom: "rgba(234, 88, 12, 0.04)"
|
|
81
|
-
},
|
|
82
|
-
{
|
|
83
|
-
line: "#84cc16",
|
|
84
|
-
top: "rgba(132, 204, 22, 0.56)",
|
|
85
|
-
bottom: "rgba(132, 204, 22, 0.04)"
|
|
84
|
+
line: "#0ea5e9",
|
|
85
|
+
top: "rgba(14, 165, 233, 0.56)",
|
|
86
|
+
bottom: "rgba(14, 165, 233, 0.04)"
|
|
86
87
|
},
|
|
88
|
+
// 11 teal
|
|
87
89
|
{
|
|
88
|
-
line: "#
|
|
89
|
-
top: "rgba(
|
|
90
|
-
bottom: "rgba(
|
|
90
|
+
line: "#14b8a6",
|
|
91
|
+
top: "rgba(20, 184, 166, 0.56)",
|
|
92
|
+
bottom: "rgba(20, 184, 166, 0.04)"
|
|
91
93
|
},
|
|
94
|
+
// 12 yellow
|
|
92
95
|
{
|
|
93
96
|
line: "#eab308",
|
|
94
97
|
top: "rgba(234, 179, 8, 0.56)",
|
|
95
98
|
bottom: "rgba(234, 179, 8, 0.04)"
|
|
96
99
|
},
|
|
100
|
+
// 13 rose
|
|
97
101
|
{
|
|
98
102
|
line: "#f43f5e",
|
|
99
103
|
top: "rgba(244, 63, 94, 0.56)",
|
|
100
104
|
bottom: "rgba(244, 63, 94, 0.04)"
|
|
101
105
|
},
|
|
106
|
+
// 14 indigo
|
|
107
|
+
{
|
|
108
|
+
line: "#6366f1",
|
|
109
|
+
top: "rgba(99, 102, 241, 0.56)",
|
|
110
|
+
bottom: "rgba(99, 102, 241, 0.04)"
|
|
111
|
+
},
|
|
112
|
+
// 15 emerald
|
|
113
|
+
{
|
|
114
|
+
line: "#10b981",
|
|
115
|
+
top: "rgba(16, 185, 129, 0.56)",
|
|
116
|
+
bottom: "rgba(16, 185, 129, 0.04)"
|
|
117
|
+
},
|
|
118
|
+
// 16 warm-gray
|
|
102
119
|
{
|
|
103
|
-
line: "#
|
|
104
|
-
top: "rgba(
|
|
105
|
-
bottom: "rgba(
|
|
120
|
+
line: "#78716c",
|
|
121
|
+
top: "rgba(120, 113, 108, 0.56)",
|
|
122
|
+
bottom: "rgba(120, 113, 108, 0.04)"
|
|
106
123
|
},
|
|
124
|
+
// 17 slate
|
|
107
125
|
{
|
|
108
126
|
line: "#64748b",
|
|
109
127
|
top: "rgba(100, 116, 139, 0.56)",
|
|
110
128
|
bottom: "rgba(100, 116, 139, 0.04)"
|
|
111
129
|
},
|
|
130
|
+
// 18 dark-slate
|
|
112
131
|
{
|
|
113
132
|
line: "#475569",
|
|
114
133
|
top: "rgba(71, 85, 105, 0.56)",
|
|
115
134
|
bottom: "rgba(71, 85, 105, 0.04)"
|
|
116
135
|
}
|
|
117
|
-
],
|
|
118
|
-
function Nt(
|
|
119
|
-
if (
|
|
120
|
-
return
|
|
121
|
-
const
|
|
122
|
-
return { line: A, top:
|
|
136
|
+
], Kt = 137.5;
|
|
137
|
+
function Nt(e) {
|
|
138
|
+
if (e < gt.length)
|
|
139
|
+
return gt[e];
|
|
140
|
+
const C = (e - gt.length) * Kt % 360, A = jt(C, 70, 50), { topColor: f, bottomColor: w } = q(A);
|
|
141
|
+
return { line: A, top: f, bottom: w };
|
|
123
142
|
}
|
|
124
|
-
function
|
|
125
|
-
series:
|
|
126
|
-
className:
|
|
127
|
-
showLegend:
|
|
143
|
+
function ge({
|
|
144
|
+
series: e,
|
|
145
|
+
className: S,
|
|
146
|
+
showLegend: C = !1,
|
|
128
147
|
onUnselectSeries: A,
|
|
129
|
-
xMeasureUnit:
|
|
130
|
-
yMeasureUnit:
|
|
148
|
+
xMeasureUnit: f = "time",
|
|
149
|
+
yMeasureUnit: w = "token",
|
|
131
150
|
optionsOverrides: B,
|
|
132
|
-
verticalLineOptions:
|
|
133
|
-
currentValueDecimals:
|
|
134
|
-
useSharedPriceScale:
|
|
151
|
+
verticalLineOptions: R,
|
|
152
|
+
currentValueDecimals: H,
|
|
153
|
+
useSharedPriceScale: T = !1,
|
|
135
154
|
showCurrentValue: Pt = !0,
|
|
136
|
-
graphTitle:
|
|
137
|
-
yScaleMin:
|
|
138
|
-
yScaleMinMultiple:
|
|
155
|
+
graphTitle: Z,
|
|
156
|
+
yScaleMin: mt,
|
|
157
|
+
yScaleMinMultiple: bt
|
|
139
158
|
}) {
|
|
140
|
-
const
|
|
159
|
+
const k = P(null), y = P(/* @__PURE__ */ new Map()), K = P(!1), J = P(/* @__PURE__ */ new Set()), ht = P(0), pt = P(!0), Q = P(
|
|
141
160
|
null
|
|
142
|
-
), Tt =
|
|
143
|
-
if (
|
|
144
|
-
const
|
|
145
|
-
if (
|
|
146
|
-
return
|
|
161
|
+
), Tt = P(null), I = P(null), U = P(null), V = Yt(), z = ct.useMemo(() => e.flatMap((t) => t.data), [e]), Ft = ct.useMemo(() => {
|
|
162
|
+
if (e.length > 0) {
|
|
163
|
+
const t = e[e.length - 1];
|
|
164
|
+
if (t.data.length > 0)
|
|
165
|
+
return t.data[t.data.length - 1];
|
|
147
166
|
}
|
|
148
|
-
}, [
|
|
149
|
-
if (!
|
|
150
|
-
const
|
|
151
|
-
for (const a of
|
|
152
|
-
a.data.length > 0 &&
|
|
153
|
-
return
|
|
154
|
-
}), [
|
|
155
|
-
|
|
156
|
-
const
|
|
157
|
-
if (
|
|
158
|
-
const i =
|
|
159
|
-
|
|
167
|
+
}, [e]), [W, tt] = ut(() => {
|
|
168
|
+
if (!Ft) return;
|
|
169
|
+
const t = /* @__PURE__ */ new Map();
|
|
170
|
+
for (const a of e)
|
|
171
|
+
a.data.length > 0 && t.set(a.label, a.data[a.data.length - 1]);
|
|
172
|
+
return t;
|
|
173
|
+
}), [et, E] = ut(null), [Ct, vt] = ut([]);
|
|
174
|
+
$(() => {
|
|
175
|
+
const t = () => {
|
|
176
|
+
if (k.current && I.current) {
|
|
177
|
+
const i = I.current.clientWidth, l = I.current.clientHeight;
|
|
178
|
+
k.current.resize(i, l), k.current.timeScale().fitContent();
|
|
160
179
|
}
|
|
161
|
-
}, a =
|
|
180
|
+
}, a = I.current, n = a ? new ResizeObserver(t) : null;
|
|
162
181
|
return a && n?.observe(a), () => {
|
|
163
182
|
a && n?.unobserve(a);
|
|
164
183
|
};
|
|
165
|
-
}, []),
|
|
166
|
-
if (!
|
|
167
|
-
const
|
|
184
|
+
}, []), $(() => {
|
|
185
|
+
if (!U.current || K.current) return;
|
|
186
|
+
const t = yt(), a = Vt(
|
|
168
187
|
"hsl(var(--foreground))",
|
|
169
188
|
"rgb(0, 0, 0)"
|
|
170
|
-
), n =
|
|
171
|
-
...
|
|
189
|
+
), n = Gt(U.current, {
|
|
190
|
+
...t,
|
|
172
191
|
rightPriceScale: {
|
|
173
|
-
...
|
|
174
|
-
visible:
|
|
192
|
+
...t.rightPriceScale || {},
|
|
193
|
+
visible: !V,
|
|
175
194
|
textColor: a
|
|
176
195
|
},
|
|
196
|
+
...V && {
|
|
197
|
+
crosshair: {
|
|
198
|
+
...t.crosshair,
|
|
199
|
+
mode: Ot.Magnet
|
|
200
|
+
}
|
|
201
|
+
},
|
|
177
202
|
...B
|
|
178
203
|
});
|
|
179
|
-
return
|
|
180
|
-
n.remove(),
|
|
204
|
+
return k.current = n, K.current = !0, () => {
|
|
205
|
+
n.remove(), k.current = null, K.current = !1, y.current.clear();
|
|
181
206
|
};
|
|
182
|
-
}, [
|
|
183
|
-
const
|
|
184
|
-
if (!
|
|
185
|
-
const n =
|
|
207
|
+
}, [V, B]), $(() => {
|
|
208
|
+
const t = k.current;
|
|
209
|
+
if (!t || e.length === 0) return;
|
|
210
|
+
const n = e.filter((o) => o.data.length > 0).length <= 1 ? mt : bt, i = f === "time" ? kt(f, z) : kt(f), l = z.map((o) => o.value), {
|
|
186
211
|
formatter: c,
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
212
|
+
tickmarksFormatter: g,
|
|
213
|
+
updateVisibleRange: L,
|
|
214
|
+
updateLastValues: b
|
|
215
|
+
} = _t(l, w, {
|
|
190
216
|
yScaleMin: n
|
|
191
217
|
});
|
|
192
|
-
|
|
193
|
-
const
|
|
194
|
-
|
|
195
|
-
const
|
|
196
|
-
|
|
218
|
+
Q.current = L, Tt.current = b;
|
|
219
|
+
const N = e.filter((o) => o.data.length > 0).map((o) => o.data[o.data.length - 1].value);
|
|
220
|
+
b(N);
|
|
221
|
+
const v = yt();
|
|
222
|
+
t.applyOptions({
|
|
197
223
|
localization: {
|
|
198
|
-
...
|
|
199
|
-
|
|
224
|
+
...v.localization || {},
|
|
225
|
+
// biome-ignore lint/suspicious/noExplicitAny: External library type compatibility
|
|
226
|
+
timeFormatter: (o) => (
|
|
200
227
|
// biome-ignore lint/suspicious/noExplicitAny: External library type compatibility
|
|
201
|
-
|
|
202
|
-
)
|
|
228
|
+
i.timeFormatter(parseFloat(o), void 0)
|
|
229
|
+
)
|
|
203
230
|
},
|
|
204
231
|
timeScale: {
|
|
205
|
-
...
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
((o) => i(parseFloat(o), void 0))
|
|
209
|
-
) : void 0,
|
|
232
|
+
...v.timeScale || {},
|
|
233
|
+
// biome-ignore lint/suspicious/noExplicitAny: External library type compatibility
|
|
234
|
+
tickMarkFormatter: i.tickMarkFormatter,
|
|
210
235
|
minBarSpacing: 0
|
|
211
236
|
}
|
|
212
237
|
});
|
|
213
|
-
const
|
|
238
|
+
const d = (z.length > 0 ? Math.min(...z.map((o) => o.value)) : 0) < 0, h = z.some((o) => o.value === 0), m = !d && h, u = e.length > 1 && !T, F = e.length > 1 && !T || V, M = Vt(
|
|
214
239
|
"hsl(var(--foreground))",
|
|
215
240
|
"rgb(0, 0, 0)"
|
|
216
241
|
);
|
|
217
|
-
|
|
242
|
+
t.applyOptions({
|
|
218
243
|
rightPriceScale: {
|
|
219
|
-
...
|
|
220
|
-
visible: !
|
|
221
|
-
textColor:
|
|
222
|
-
...
|
|
244
|
+
...v.rightPriceScale || {},
|
|
245
|
+
visible: !F,
|
|
246
|
+
textColor: M,
|
|
247
|
+
...m && {
|
|
223
248
|
scaleMargins: {
|
|
224
249
|
top: 0.3,
|
|
225
250
|
bottom: 0
|
|
@@ -227,83 +252,85 @@ function ce({
|
|
|
227
252
|
}
|
|
228
253
|
}
|
|
229
254
|
});
|
|
230
|
-
const
|
|
231
|
-
for (const o of
|
|
232
|
-
if (!
|
|
233
|
-
const r =
|
|
234
|
-
r && (
|
|
255
|
+
const ot = new Set(y.current.keys()), nt = new Set(e.map((o) => o.label));
|
|
256
|
+
for (const o of ot)
|
|
257
|
+
if (!nt.has(o)) {
|
|
258
|
+
const r = y.current.get(o);
|
|
259
|
+
r && (t.removeSeries(r), y.current.delete(o));
|
|
235
260
|
}
|
|
236
|
-
const
|
|
237
|
-
let
|
|
238
|
-
for (let o = 0; o <
|
|
239
|
-
const r =
|
|
261
|
+
const Mt = Ht(), rt = [];
|
|
262
|
+
let _ = 0;
|
|
263
|
+
for (let o = 0; o < e.length; o++) {
|
|
264
|
+
const r = e[o], it = Nt(o), X = r.lineColor ?? r.color ?? it.line;
|
|
240
265
|
let D, G;
|
|
241
266
|
if (r.lineColor ?? r.color)
|
|
242
267
|
if (r.topColor && r.bottomColor)
|
|
243
268
|
D = r.topColor, G = r.bottomColor;
|
|
244
269
|
else if (r.topColor) {
|
|
245
|
-
const s =
|
|
270
|
+
const s = q(X);
|
|
246
271
|
D = r.topColor, G = s.bottomColor;
|
|
247
272
|
} else if (r.bottomColor)
|
|
248
|
-
D =
|
|
273
|
+
D = q(X).topColor, G = r.bottomColor;
|
|
249
274
|
else {
|
|
250
|
-
const s =
|
|
275
|
+
const s = q(X);
|
|
251
276
|
D = s.topColor, G = s.bottomColor;
|
|
252
277
|
}
|
|
253
278
|
else
|
|
254
|
-
D = r.topColor ||
|
|
279
|
+
D = r.topColor || it.top, G = r.bottomColor || it.bottom;
|
|
255
280
|
if (r.data.length === 0) {
|
|
256
|
-
const s =
|
|
257
|
-
s && (
|
|
281
|
+
const s = y.current.get(r.label);
|
|
282
|
+
s && (t.removeSeries(s), y.current.delete(r.label));
|
|
258
283
|
continue;
|
|
259
284
|
}
|
|
260
|
-
const
|
|
261
|
-
u &&
|
|
285
|
+
const zt = (r.data.length > 0 ? Math.min(...r.data.map((s) => s.value)) : 0) < 0, Et = r.data.some((s) => s.value === 0), $t = !zt && Et, St = T || !u || _ === 0 ? "right" : `scale-${_}`;
|
|
286
|
+
u && rt.push({
|
|
262
287
|
priceScaleId: St || "right",
|
|
263
|
-
shouldPreventNegativeAxis:
|
|
264
|
-
seriesIndex:
|
|
288
|
+
shouldPreventNegativeAxis: $t,
|
|
289
|
+
seriesIndex: _
|
|
265
290
|
});
|
|
266
|
-
const wt = (
|
|
267
|
-
lineColor:
|
|
291
|
+
const wt = (T || !u) && n !== void 0 && typeof n == "number", Rt = {
|
|
292
|
+
lineColor: X,
|
|
268
293
|
topColor: D,
|
|
269
294
|
bottomColor: G,
|
|
270
295
|
priceScaleId: St,
|
|
271
296
|
priceFormat: {
|
|
272
297
|
type: "custom",
|
|
298
|
+
minMove: 0.01,
|
|
273
299
|
formatter: wt && typeof n == "number" ? (s) => c(
|
|
274
300
|
s < n ? n : s
|
|
275
|
-
) : c
|
|
301
|
+
) : c,
|
|
302
|
+
tickmarksFormatter: g
|
|
276
303
|
},
|
|
277
304
|
autoscaleInfoProvider: (s) => {
|
|
278
305
|
if (!wt) return s();
|
|
279
|
-
const
|
|
280
|
-
if (
|
|
281
|
-
const
|
|
282
|
-
|
|
306
|
+
const st = s();
|
|
307
|
+
if (st?.priceRange) {
|
|
308
|
+
const Dt = n;
|
|
309
|
+
st.priceRange.minValue = Dt;
|
|
283
310
|
}
|
|
284
|
-
return
|
|
311
|
+
return st;
|
|
285
312
|
}
|
|
286
313
|
};
|
|
287
|
-
let O =
|
|
314
|
+
let O = y.current.get(r.label);
|
|
288
315
|
O ? (O.applyOptions(Rt), O.setData(
|
|
289
316
|
r.data.map((s) => ({
|
|
290
317
|
...s,
|
|
291
318
|
time: s.time
|
|
292
319
|
}))
|
|
293
|
-
)) : (O =
|
|
294
|
-
...
|
|
320
|
+
)) : (O = t.addSeries(Bt, {
|
|
321
|
+
...Mt,
|
|
295
322
|
...Rt
|
|
296
323
|
}), O.setData(
|
|
297
324
|
r.data.map((s) => ({
|
|
298
325
|
...s,
|
|
299
326
|
time: s.time
|
|
300
327
|
}))
|
|
301
|
-
),
|
|
328
|
+
), y.current.set(r.label, O)), _++;
|
|
302
329
|
}
|
|
303
|
-
if (u &&
|
|
304
|
-
for (const o of
|
|
330
|
+
if (u && rt.length > 0)
|
|
331
|
+
for (const o of rt)
|
|
305
332
|
try {
|
|
306
|
-
const r =
|
|
333
|
+
const r = t.priceScale(o.priceScaleId);
|
|
307
334
|
r && r.applyOptions({
|
|
308
335
|
visible: !1,
|
|
309
336
|
autoScale: !0,
|
|
@@ -319,7 +346,7 @@ function ce({
|
|
|
319
346
|
borderVisible: !0,
|
|
320
347
|
borderColor: "rgba(224, 227, 235, 0.1)",
|
|
321
348
|
entireTextOnly: !1,
|
|
322
|
-
textColor:
|
|
349
|
+
textColor: M
|
|
323
350
|
});
|
|
324
351
|
} catch (r) {
|
|
325
352
|
console.warn(
|
|
@@ -329,15 +356,15 @@ function ce({
|
|
|
329
356
|
}
|
|
330
357
|
else if (!u)
|
|
331
358
|
try {
|
|
332
|
-
const o =
|
|
359
|
+
const o = t.priceScale("right");
|
|
333
360
|
o && o.applyOptions({
|
|
334
|
-
visible:
|
|
361
|
+
visible: !V,
|
|
335
362
|
autoScale: !0,
|
|
336
363
|
scaleMargins: {
|
|
337
364
|
top: 0.1,
|
|
338
365
|
// No bottom margin when yScaleMin is set so the scale doesn't extend below the minimum (avoids negative labels like -10M)
|
|
339
|
-
bottom: n !== void 0 ||
|
|
340
|
-
...
|
|
366
|
+
bottom: n !== void 0 || m ? 0 : 0.1,
|
|
367
|
+
...m && {
|
|
341
368
|
top: 0.3
|
|
342
369
|
}
|
|
343
370
|
},
|
|
@@ -345,133 +372,133 @@ function ce({
|
|
|
345
372
|
borderVisible: !0,
|
|
346
373
|
borderColor: "rgba(224, 227, 235, 0.1)",
|
|
347
374
|
entireTextOnly: !1,
|
|
348
|
-
textColor:
|
|
375
|
+
textColor: M
|
|
349
376
|
});
|
|
350
377
|
} catch {
|
|
351
378
|
}
|
|
352
|
-
n !== void 0 && (
|
|
379
|
+
n !== void 0 && !V && (T || !u) && t.applyOptions({
|
|
353
380
|
handleScroll: {
|
|
354
381
|
vertTouchDrag: !1
|
|
355
382
|
}
|
|
356
383
|
});
|
|
357
|
-
const
|
|
358
|
-
(
|
|
359
|
-
const
|
|
360
|
-
for (const o of
|
|
361
|
-
o.data.length > 0 &&
|
|
362
|
-
|
|
384
|
+
const at = new Set(e.map((o) => o.label)), At = at.size !== J.current.size || [...at].some((o) => !J.current.has(o)), It = z.length !== ht.current;
|
|
385
|
+
(pt.current || At || It || V) && (t.timeScale().fitContent(), pt.current = !1), J.current = at, ht.current = z.length;
|
|
386
|
+
const lt = /* @__PURE__ */ new Map();
|
|
387
|
+
for (const o of e)
|
|
388
|
+
o.data.length > 0 && lt.set(o.label, o.data[o.data.length - 1]);
|
|
389
|
+
tt(lt.size > 0 ? lt : void 0);
|
|
363
390
|
}, [
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
]),
|
|
373
|
-
const
|
|
374
|
-
if (!
|
|
375
|
-
const a =
|
|
391
|
+
e,
|
|
392
|
+
z,
|
|
393
|
+
f,
|
|
394
|
+
w,
|
|
395
|
+
V,
|
|
396
|
+
T,
|
|
397
|
+
mt,
|
|
398
|
+
bt
|
|
399
|
+
]), $(() => {
|
|
400
|
+
const t = k.current;
|
|
401
|
+
if (!t || e.length === 0) return;
|
|
402
|
+
const a = e.length === 1;
|
|
376
403
|
let n;
|
|
377
|
-
for (const l of
|
|
404
|
+
for (const l of e)
|
|
378
405
|
if (l.data.length > 0) {
|
|
379
406
|
n = l.data[l.data.length - 1].time;
|
|
380
407
|
break;
|
|
381
408
|
}
|
|
382
409
|
if (!n) return;
|
|
383
410
|
const i = (l) => {
|
|
384
|
-
const { time: c = n, seriesData:
|
|
385
|
-
if (!
|
|
386
|
-
const
|
|
387
|
-
for (const d of
|
|
388
|
-
d.data.length > 0 &&
|
|
389
|
-
if (
|
|
390
|
-
|
|
391
|
-
else if (
|
|
392
|
-
const
|
|
393
|
-
if (
|
|
394
|
-
const
|
|
395
|
-
|
|
411
|
+
const { time: c = n, seriesData: g, point: L } = l || {}, b = Array.from(y.current.values());
|
|
412
|
+
if (!L || !c) {
|
|
413
|
+
const x = /* @__PURE__ */ new Map();
|
|
414
|
+
for (const d of e)
|
|
415
|
+
d.data.length > 0 && x.set(d.label, d.data[d.data.length - 1]);
|
|
416
|
+
if (tt(x.size > 0 ? x : void 0), a || T)
|
|
417
|
+
E(null);
|
|
418
|
+
else if (b[0] && n) {
|
|
419
|
+
const h = t.timeScale().timeToCoordinate(n), m = e[0];
|
|
420
|
+
if (m.data.length > 0) {
|
|
421
|
+
const u = m.data[m.data.length - 1].value, F = b[0].priceToCoordinate(u);
|
|
422
|
+
h !== null && F !== null && E({ x: h, y: F });
|
|
396
423
|
}
|
|
397
424
|
}
|
|
398
425
|
return;
|
|
399
426
|
}
|
|
400
|
-
const
|
|
401
|
-
let
|
|
402
|
-
for (let
|
|
403
|
-
const d =
|
|
404
|
-
if (!
|
|
405
|
-
const
|
|
406
|
-
|
|
427
|
+
const N = /* @__PURE__ */ new Map();
|
|
428
|
+
let v;
|
|
429
|
+
for (let x = 0; x < e.length; x++) {
|
|
430
|
+
const d = e[x], h = b[x];
|
|
431
|
+
if (!h) continue;
|
|
432
|
+
const m = g?.get(h), u = m && "value" in m ? m.value : void 0, F = d.data[d.data.length - 1], M = u !== void 0 ? u : F?.value ?? 0;
|
|
433
|
+
x === 0 && (v = M), N.set(d.label, { value: M, time: c });
|
|
407
434
|
}
|
|
408
|
-
if (
|
|
409
|
-
const d =
|
|
410
|
-
if (d !== null &&
|
|
411
|
-
const
|
|
412
|
-
if (
|
|
413
|
-
const
|
|
435
|
+
if (tt(N), v !== void 0 && b[0]) {
|
|
436
|
+
const d = t.timeScale().timeToCoordinate(c), h = b[0].priceToCoordinate(v);
|
|
437
|
+
if (d !== null && h !== null) {
|
|
438
|
+
const m = I.current;
|
|
439
|
+
if (m) {
|
|
440
|
+
const u = m.querySelector(
|
|
414
441
|
".LightweightChart"
|
|
415
442
|
);
|
|
416
|
-
if (
|
|
417
|
-
const
|
|
418
|
-
|
|
443
|
+
if (u) {
|
|
444
|
+
const F = u.getBoundingClientRect(), M = m.getBoundingClientRect(), ot = d + (F.left - M.left), nt = h + (F.top - M.top);
|
|
445
|
+
E({ x: ot, y: nt });
|
|
419
446
|
} else
|
|
420
|
-
|
|
447
|
+
E({ x: d, y: h });
|
|
421
448
|
} else
|
|
422
|
-
|
|
449
|
+
E({ x: d, y: h });
|
|
423
450
|
} else
|
|
424
|
-
|
|
451
|
+
E(null);
|
|
425
452
|
} else
|
|
426
|
-
|
|
453
|
+
E(null);
|
|
427
454
|
};
|
|
428
|
-
return
|
|
429
|
-
const l = Array.from(
|
|
430
|
-
if (l[0] && n &&
|
|
431
|
-
const
|
|
432
|
-
|
|
455
|
+
return t.subscribeCrosshairMove(i), V && t.subscribeClick(i), !a && !T && requestAnimationFrame(() => {
|
|
456
|
+
const l = Array.from(y.current.values());
|
|
457
|
+
if (l[0] && n && e[0]?.data.length > 0) {
|
|
458
|
+
const g = t.timeScale().timeToCoordinate(n), L = e[0].data[e[0].data.length - 1].value, b = l[0].priceToCoordinate(L);
|
|
459
|
+
g !== null && b !== null && E({ x: g, y: b });
|
|
433
460
|
}
|
|
434
461
|
}), () => {
|
|
435
|
-
|
|
462
|
+
t.unsubscribeCrosshairMove(i), V && t.unsubscribeClick(i);
|
|
436
463
|
};
|
|
437
|
-
}, [
|
|
438
|
-
const
|
|
439
|
-
if (!
|
|
440
|
-
const a =
|
|
464
|
+
}, [e, T, V]), $(() => {
|
|
465
|
+
const t = k.current;
|
|
466
|
+
if (!t || e.length === 0) return;
|
|
467
|
+
const a = t.timeScale(), n = Math.max(...e.map((l) => l.data.length)), i = () => {
|
|
441
468
|
if (n === 0) return;
|
|
442
469
|
const l = a.getVisibleLogicalRange();
|
|
443
470
|
if (!l) return;
|
|
444
471
|
const c = {
|
|
445
472
|
from: 0,
|
|
446
473
|
to: n - 1
|
|
447
|
-
},
|
|
448
|
-
if (
|
|
449
|
-
const
|
|
450
|
-
for (const
|
|
451
|
-
for (let
|
|
452
|
-
|
|
453
|
-
|
|
474
|
+
}, g = typeof l.from == "number" ? l.from : 0, L = typeof l.to == "number" ? l.to : n - 1;
|
|
475
|
+
if (Q.current) {
|
|
476
|
+
const x = Math.max(0, Math.floor(g)), d = Math.min(n - 1, Math.ceil(L)), h = [];
|
|
477
|
+
for (const m of e)
|
|
478
|
+
for (let u = x; u <= d && u < m.data.length; u++)
|
|
479
|
+
h.push(m.data[u].value);
|
|
480
|
+
h.length > 0 && Q.current(h);
|
|
454
481
|
}
|
|
455
|
-
const
|
|
456
|
-
let
|
|
457
|
-
const
|
|
458
|
-
|
|
482
|
+
const b = 0.01;
|
|
483
|
+
let N = !1;
|
|
484
|
+
const v = { ...l };
|
|
485
|
+
g < c.from - b && (v.from = c.from, N = !0), L > c.to + b && (v.to = c.to, N = !0), N && a.setVisibleLogicalRange(v);
|
|
459
486
|
};
|
|
460
487
|
return a.subscribeVisibleLogicalRangeChange(i), () => {
|
|
461
488
|
a.unsubscribeVisibleLogicalRangeChange(
|
|
462
489
|
i
|
|
463
490
|
);
|
|
464
491
|
};
|
|
465
|
-
}, [
|
|
466
|
-
const
|
|
467
|
-
if (
|
|
468
|
-
const i =
|
|
469
|
-
for (const c of
|
|
470
|
-
const
|
|
492
|
+
}, [e]), $(() => {
|
|
493
|
+
const t = k.current, a = Array.from(y.current.values()), n = [];
|
|
494
|
+
if (t && a.length > 0 && R) {
|
|
495
|
+
const i = Wt(), l = a[0];
|
|
496
|
+
for (const c of R) {
|
|
497
|
+
const g = new qt(t, l, c.xCoordinate, {
|
|
471
498
|
...i,
|
|
472
499
|
...c.options || {}
|
|
473
500
|
});
|
|
474
|
-
l.attachPrimitive(
|
|
501
|
+
l.attachPrimitive(g), n.push(g);
|
|
475
502
|
}
|
|
476
503
|
}
|
|
477
504
|
return () => {
|
|
@@ -481,93 +508,105 @@ function ce({
|
|
|
481
508
|
i.detachPrimitive(l);
|
|
482
509
|
}
|
|
483
510
|
};
|
|
484
|
-
}, [
|
|
485
|
-
const
|
|
486
|
-
if (!
|
|
511
|
+
}, [R]), $(() => {
|
|
512
|
+
const t = k.current;
|
|
513
|
+
if (!t || !R?.length) {
|
|
487
514
|
vt([]);
|
|
488
515
|
return;
|
|
489
516
|
}
|
|
490
517
|
const a = () => {
|
|
491
|
-
const l =
|
|
518
|
+
const l = t.timeScale(), c = R.map((g) => l.timeToCoordinate(g.xCoordinate) ?? null);
|
|
492
519
|
vt(c);
|
|
493
520
|
};
|
|
494
521
|
a();
|
|
495
|
-
const n =
|
|
522
|
+
const n = t.timeScale(), i = () => {
|
|
496
523
|
a();
|
|
497
524
|
};
|
|
498
525
|
return n.subscribeVisibleLogicalRangeChange(i), () => {
|
|
499
526
|
n.unsubscribeVisibleLogicalRangeChange(i);
|
|
500
527
|
};
|
|
501
|
-
}, [
|
|
502
|
-
const
|
|
503
|
-
if (
|
|
504
|
-
const
|
|
505
|
-
if (
|
|
506
|
-
return
|
|
528
|
+
}, [R]);
|
|
529
|
+
const Y = e.length === 1, xt = ct.useMemo(() => {
|
|
530
|
+
if (Y && e.length > 0) {
|
|
531
|
+
const t = e[0];
|
|
532
|
+
if (t.data.length > 0)
|
|
533
|
+
return t.data[t.data.length - 1];
|
|
507
534
|
}
|
|
508
|
-
}, [
|
|
509
|
-
return /* @__PURE__ */
|
|
535
|
+
}, [Y, e]);
|
|
536
|
+
return /* @__PURE__ */ j(
|
|
510
537
|
"div",
|
|
511
538
|
{
|
|
512
|
-
ref:
|
|
513
|
-
className:
|
|
539
|
+
ref: I,
|
|
540
|
+
className: dt(
|
|
514
541
|
"relative z-[1] w-full h-full overflow-hidden p-0",
|
|
515
|
-
|
|
542
|
+
S
|
|
516
543
|
),
|
|
517
544
|
children: [
|
|
518
|
-
|
|
519
|
-
|
|
545
|
+
Z != null && Z !== !1 && Y ? /* @__PURE__ */ p("div", { className: "absolute top-2 left-2 right-2 z-[100] pointer-events-none", children: /* @__PURE__ */ p("div", { className: "text-xl sm:text-2xl font-semibold text-foreground whitespace-nowrap overflow-hidden text-ellipsis", children: Z }) }) : Pt && Y && xt && /* @__PURE__ */ p(
|
|
546
|
+
Xt,
|
|
520
547
|
{
|
|
521
548
|
point: xt,
|
|
522
|
-
xMeasureUnit:
|
|
523
|
-
yMeasureUnit:
|
|
524
|
-
decimals:
|
|
549
|
+
xMeasureUnit: f,
|
|
550
|
+
yMeasureUnit: w,
|
|
551
|
+
decimals: H
|
|
552
|
+
}
|
|
553
|
+
),
|
|
554
|
+
W && et && /* @__PURE__ */ p(
|
|
555
|
+
Lt,
|
|
556
|
+
{
|
|
557
|
+
points: W,
|
|
558
|
+
xMeasureUnit: f,
|
|
559
|
+
yMeasureUnit: w,
|
|
560
|
+
series: e,
|
|
561
|
+
position: et,
|
|
562
|
+
containerRef: I,
|
|
563
|
+
decimals: H
|
|
525
564
|
}
|
|
526
565
|
),
|
|
527
|
-
|
|
528
|
-
|
|
566
|
+
W && !et && !Y && V && /* @__PURE__ */ p(
|
|
567
|
+
Lt,
|
|
529
568
|
{
|
|
530
|
-
points:
|
|
531
|
-
xMeasureUnit:
|
|
532
|
-
yMeasureUnit:
|
|
533
|
-
series:
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
569
|
+
points: W,
|
|
570
|
+
xMeasureUnit: f,
|
|
571
|
+
yMeasureUnit: w,
|
|
572
|
+
series: e,
|
|
573
|
+
containerRef: I,
|
|
574
|
+
decimals: H,
|
|
575
|
+
className: "top-2 left-2"
|
|
537
576
|
}
|
|
538
577
|
),
|
|
539
|
-
|
|
540
|
-
|
|
578
|
+
C && /* @__PURE__ */ p(Jt, { series: e, onUnselect: A }),
|
|
579
|
+
R && R.length > 0 && Ct.length === R.length && /* @__PURE__ */ p(
|
|
541
580
|
"div",
|
|
542
581
|
{
|
|
543
582
|
className: "absolute inset-0 z-[5] pointer-events-none",
|
|
544
583
|
"aria-hidden": !0,
|
|
545
|
-
children:
|
|
546
|
-
const n = Ct[a], i =
|
|
584
|
+
children: R.map((t, a) => {
|
|
585
|
+
const n = Ct[a], i = t.options ?? {}, l = i.showLabel !== !1;
|
|
547
586
|
if (n === null || !l) return null;
|
|
548
|
-
const { labelText: c, valueStr:
|
|
587
|
+
const { labelText: c, valueStr: g } = Zt(
|
|
549
588
|
i,
|
|
550
|
-
|
|
551
|
-
|
|
589
|
+
w,
|
|
590
|
+
H
|
|
552
591
|
);
|
|
553
|
-
if (!(c ||
|
|
554
|
-
const
|
|
555
|
-
return /* @__PURE__ */
|
|
592
|
+
if (!(c || g)) return null;
|
|
593
|
+
const b = i.labelBackgroundColor ?? i.color ?? "hsl(var(--background))", N = i.labelTextColor ?? "hsl(var(--foreground))", v = `${String(t.xCoordinate)}-${c}`;
|
|
594
|
+
return /* @__PURE__ */ j(
|
|
556
595
|
"div",
|
|
557
596
|
{
|
|
558
597
|
className: "absolute top-2 px-2 py-1 rounded text-xs font-medium whitespace-nowrap shadow-sm border border-border",
|
|
559
598
|
style: {
|
|
560
599
|
left: n,
|
|
561
600
|
transform: "translateX(-50%)",
|
|
562
|
-
backgroundColor:
|
|
563
|
-
color:
|
|
601
|
+
backgroundColor: b,
|
|
602
|
+
color: N
|
|
564
603
|
},
|
|
565
604
|
children: [
|
|
566
605
|
c && /* @__PURE__ */ p("span", { className: "block", children: c }),
|
|
567
|
-
|
|
606
|
+
g && /* @__PURE__ */ p("span", { className: dt("block", c && "mt-0.5"), children: g })
|
|
568
607
|
]
|
|
569
608
|
},
|
|
570
|
-
|
|
609
|
+
v
|
|
571
610
|
);
|
|
572
611
|
})
|
|
573
612
|
}
|
|
@@ -575,7 +614,7 @@ function ce({
|
|
|
575
614
|
/* @__PURE__ */ p(
|
|
576
615
|
"div",
|
|
577
616
|
{
|
|
578
|
-
ref:
|
|
617
|
+
ref: U,
|
|
579
618
|
className: "LightweightChart w-full h-full overflow-hidden"
|
|
580
619
|
}
|
|
581
620
|
)
|
|
@@ -583,16 +622,16 @@ function ce({
|
|
|
583
622
|
}
|
|
584
623
|
);
|
|
585
624
|
}
|
|
586
|
-
function
|
|
587
|
-
series:
|
|
588
|
-
onUnselect:
|
|
625
|
+
function Jt({
|
|
626
|
+
series: e,
|
|
627
|
+
onUnselect: S
|
|
589
628
|
}) {
|
|
590
|
-
return /* @__PURE__ */ p("div", { className: "absolute top-0 left-2 z-[10] flex flex-wrap gap-2", children:
|
|
591
|
-
const
|
|
592
|
-
return /* @__PURE__ */
|
|
629
|
+
return /* @__PURE__ */ p("div", { className: "absolute top-0 left-2 z-[10] flex flex-wrap gap-2", children: e.map((C, A) => {
|
|
630
|
+
const f = Nt(A), w = (C.lineColor ?? C.color) || f.line, B = C.data.length === 0;
|
|
631
|
+
return /* @__PURE__ */ j(
|
|
593
632
|
"div",
|
|
594
633
|
{
|
|
595
|
-
className:
|
|
634
|
+
className: dt(
|
|
596
635
|
"flex items-center gap-1.5 px-2 py-1 bg-background/80 backdrop-blur-sm rounded border border-border",
|
|
597
636
|
B && "opacity-50"
|
|
598
637
|
),
|
|
@@ -601,23 +640,23 @@ function qt({
|
|
|
601
640
|
"div",
|
|
602
641
|
{
|
|
603
642
|
className: "w-3 h-3 rounded-sm",
|
|
604
|
-
style: { backgroundColor:
|
|
643
|
+
style: { backgroundColor: w }
|
|
605
644
|
}
|
|
606
645
|
),
|
|
607
|
-
/* @__PURE__ */
|
|
608
|
-
|
|
646
|
+
/* @__PURE__ */ j("span", { className: "text-[10px] sm:text-xs font-medium text-foreground", children: [
|
|
647
|
+
C.label,
|
|
609
648
|
B && " (no data)"
|
|
610
649
|
] }),
|
|
611
|
-
|
|
650
|
+
S && /* @__PURE__ */ p(
|
|
612
651
|
"button",
|
|
613
652
|
{
|
|
614
653
|
type: "button",
|
|
615
|
-
onClick: (
|
|
616
|
-
|
|
654
|
+
onClick: (R) => {
|
|
655
|
+
R.stopPropagation(), S(C.label);
|
|
617
656
|
},
|
|
618
657
|
className: "ml-1 flex items-center justify-center w-4 h-4 rounded-sm hover:bg-muted transition-colors cursor-pointer",
|
|
619
|
-
"aria-label": `Remove ${
|
|
620
|
-
children: /* @__PURE__ */
|
|
658
|
+
"aria-label": `Remove ${C.label}`,
|
|
659
|
+
children: /* @__PURE__ */ j(
|
|
621
660
|
"svg",
|
|
622
661
|
{
|
|
623
662
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -642,13 +681,13 @@ function qt({
|
|
|
642
681
|
)
|
|
643
682
|
]
|
|
644
683
|
},
|
|
645
|
-
|
|
684
|
+
C.label
|
|
646
685
|
);
|
|
647
686
|
}) });
|
|
648
687
|
}
|
|
649
688
|
export {
|
|
650
|
-
|
|
651
|
-
|
|
689
|
+
gt as DEFAULT_SERIES_COLORS,
|
|
690
|
+
ge as Graph,
|
|
652
691
|
Nt as getSeriesColorPalette,
|
|
653
|
-
|
|
692
|
+
Zt as getVerticalLineTooltipContent
|
|
654
693
|
};
|