@gearbox-protocol/permissionless-ui 1.23.0 → 1.23.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/buttons/range-buttons/range-buttons.cjs +1 -1
- package/dist/cjs/components/graph/graph-tooltip.cjs +1 -1
- package/dist/cjs/components/graph/graph-view.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/tab-control/tab-control.cjs +1 -1
- package/dist/cjs/components/trading-view/trading-view.cjs +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/utils/colors.cjs +1 -1
- package/dist/cjs/utils/index.cjs +1 -1
- package/dist/esm/components/buttons/range-buttons/range-buttons.js +1 -1
- package/dist/esm/components/graph/graph-tooltip.js +17 -17
- package/dist/esm/components/graph/graph-view.js +21 -21
- package/dist/esm/components/graph/graph.js +286 -224
- package/dist/esm/components/graph/index.js +11 -10
- package/dist/esm/components/index.js +440 -439
- package/dist/esm/components/tab-control/tab-control.js +49 -49
- package/dist/esm/components/trading-view/trading-view.js +70 -70
- package/dist/esm/index.js +583 -581
- package/dist/esm/utils/colors.js +40 -28
- package/dist/esm/utils/index.js +78 -77
- package/dist/globals.css +1 -1
- package/dist/types/components/graph/graph.d.ts +12 -0
- package/dist/types/components/tab-control/tab-control.d.ts +1 -1
- package/dist/types/utils/colors.d.ts +8 -0
- package/package.json +1 -1
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { createChart as
|
|
1
|
+
import { jsxs as _, jsx as y } from "react/jsx-runtime";
|
|
2
|
+
import { createChart as Rt } from "lightweight-charts";
|
|
3
3
|
import * as ot from "react";
|
|
4
|
-
import { useRef as
|
|
5
|
-
import { useIsMobile as
|
|
4
|
+
import { useRef as x, useState as ut, useEffect as E } from "react";
|
|
5
|
+
import { useIsMobile as wt } from "../../hooks/use-media-query.js";
|
|
6
6
|
import { cn as mt } from "../../utils/cn.js";
|
|
7
|
-
import {
|
|
8
|
-
import { getDefaultOptions as
|
|
9
|
-
import { getXFormatter as
|
|
10
|
-
import { GraphCurrentValue as
|
|
11
|
-
import { GraphTooltip as
|
|
12
|
-
import { VertLine as
|
|
13
|
-
const
|
|
7
|
+
import { hslToHex as Vt, generateColorsFromBase as $, resolveCSSColor as ft } from "../../utils/colors.js";
|
|
8
|
+
import { getDefaultOptions as gt, getDefaultSeries as Lt, getDefaultVerticalLine as Pt } from "./default-config.js";
|
|
9
|
+
import { getXFormatter as dt, createAdaptiveYAxisFormatter as Mt } from "./formatters.js";
|
|
10
|
+
import { GraphCurrentValue as Nt } from "./graph-current-value.js";
|
|
11
|
+
import { GraphTooltip as At } from "./graph-tooltip.js";
|
|
12
|
+
import { VertLine as Ft } from "./plugins/vertical-line.js";
|
|
13
|
+
const rt = [
|
|
14
14
|
{
|
|
15
15
|
line: "#02c39a",
|
|
16
16
|
top: "rgba(2, 195, 154, 0.56)",
|
|
@@ -21,16 +21,16 @@ const $ = [
|
|
|
21
21
|
top: "rgba(59, 130, 246, 0.56)",
|
|
22
22
|
bottom: "rgba(59, 130, 246, 0.04)"
|
|
23
23
|
},
|
|
24
|
-
{
|
|
25
|
-
line: "#f59e0b",
|
|
26
|
-
top: "rgba(245, 158, 11, 0.56)",
|
|
27
|
-
bottom: "rgba(245, 158, 11, 0.04)"
|
|
28
|
-
},
|
|
29
24
|
{
|
|
30
25
|
line: "#ef4444",
|
|
31
26
|
top: "rgba(239, 68, 68, 0.56)",
|
|
32
27
|
bottom: "rgba(239, 68, 68, 0.04)"
|
|
33
28
|
},
|
|
29
|
+
{
|
|
30
|
+
line: "#f59e0b",
|
|
31
|
+
top: "rgba(245, 158, 11, 0.56)",
|
|
32
|
+
bottom: "rgba(245, 158, 11, 0.04)"
|
|
33
|
+
},
|
|
34
34
|
{
|
|
35
35
|
line: "#8b5cf6",
|
|
36
36
|
top: "rgba(139, 92, 246, 0.56)",
|
|
@@ -41,109 +41,170 @@ const $ = [
|
|
|
41
41
|
top: "rgba(236, 72, 153, 0.56)",
|
|
42
42
|
bottom: "rgba(236, 72, 153, 0.04)"
|
|
43
43
|
},
|
|
44
|
+
{
|
|
45
|
+
line: "#06b6d4",
|
|
46
|
+
top: "rgba(6, 182, 212, 0.56)",
|
|
47
|
+
bottom: "rgba(6, 182, 212, 0.04)"
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
line: "#0ea5e9",
|
|
51
|
+
top: "rgba(14, 165, 233, 0.56)",
|
|
52
|
+
bottom: "rgba(14, 165, 233, 0.04)"
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
line: "#6366f1",
|
|
56
|
+
top: "rgba(99, 102, 241, 0.56)",
|
|
57
|
+
bottom: "rgba(99, 102, 241, 0.04)"
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
line: "#d946ef",
|
|
61
|
+
top: "rgba(217, 70, 239, 0.56)",
|
|
62
|
+
bottom: "rgba(217, 70, 239, 0.04)"
|
|
63
|
+
},
|
|
44
64
|
{
|
|
45
65
|
line: "#10b981",
|
|
46
66
|
top: "rgba(16, 185, 129, 0.56)",
|
|
47
67
|
bottom: "rgba(16, 185, 129, 0.04)"
|
|
48
68
|
},
|
|
49
69
|
{
|
|
50
|
-
line: "#
|
|
51
|
-
top: "rgba(
|
|
52
|
-
bottom: "rgba(
|
|
70
|
+
line: "#ea580c",
|
|
71
|
+
top: "rgba(234, 88, 12, 0.56)",
|
|
72
|
+
bottom: "rgba(234, 88, 12, 0.04)"
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
line: "#84cc16",
|
|
76
|
+
top: "rgba(132, 204, 22, 0.56)",
|
|
77
|
+
bottom: "rgba(132, 204, 22, 0.04)"
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
line: "#0d9488",
|
|
81
|
+
top: "rgba(13, 148, 136, 0.56)",
|
|
82
|
+
bottom: "rgba(13, 148, 136, 0.04)"
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
line: "#eab308",
|
|
86
|
+
top: "rgba(234, 179, 8, 0.56)",
|
|
87
|
+
bottom: "rgba(234, 179, 8, 0.04)"
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
line: "#f43f5e",
|
|
91
|
+
top: "rgba(244, 63, 94, 0.56)",
|
|
92
|
+
bottom: "rgba(244, 63, 94, 0.04)"
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
line: "#d97706",
|
|
96
|
+
top: "rgba(217, 119, 6, 0.56)",
|
|
97
|
+
bottom: "rgba(217, 119, 6, 0.04)"
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
line: "#64748b",
|
|
101
|
+
top: "rgba(100, 116, 139, 0.56)",
|
|
102
|
+
bottom: "rgba(100, 116, 139, 0.04)"
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
line: "#475569",
|
|
106
|
+
top: "rgba(71, 85, 105, 0.56)",
|
|
107
|
+
bottom: "rgba(71, 85, 105, 0.04)"
|
|
53
108
|
}
|
|
54
|
-
];
|
|
55
|
-
function
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
109
|
+
], Tt = 137.5;
|
|
110
|
+
function bt(t) {
|
|
111
|
+
if (t < rt.length)
|
|
112
|
+
return rt[t];
|
|
113
|
+
const v = (t - rt.length) * Tt % 360, k = Vt(v, 70, 50), { topColor: C, bottomColor: N } = $(k);
|
|
114
|
+
return { line: k, top: C, bottom: N };
|
|
115
|
+
}
|
|
116
|
+
function qt({
|
|
117
|
+
series: t,
|
|
118
|
+
className: G,
|
|
119
|
+
showLegend: v = !1,
|
|
120
|
+
onUnselectSeries: k,
|
|
121
|
+
xMeasureUnit: C = "time",
|
|
122
|
+
yMeasureUnit: N = "token",
|
|
123
|
+
optionsOverrides: j,
|
|
124
|
+
verticalLineOptions: B,
|
|
64
125
|
currentValueDecimals: nt
|
|
65
126
|
}) {
|
|
66
|
-
const
|
|
127
|
+
const R = x(null), h = x(/* @__PURE__ */ new Map()), q = x(!1), W = x(/* @__PURE__ */ new Set()), at = x(0), lt = x(!0), X = x(
|
|
67
128
|
null
|
|
68
|
-
),
|
|
69
|
-
if (
|
|
70
|
-
const
|
|
71
|
-
if (
|
|
72
|
-
return
|
|
129
|
+
), pt = x(null), A = x(null), Z = x(null), O = wt(), L = ot.useMemo(() => t.flatMap((o) => o.data), [t]), ht = ot.useMemo(() => {
|
|
130
|
+
if (t.length > 0) {
|
|
131
|
+
const o = t[t.length - 1];
|
|
132
|
+
if (o.data.length > 0)
|
|
133
|
+
return o.data[o.data.length - 1];
|
|
73
134
|
}
|
|
74
|
-
}, [
|
|
75
|
-
if (!
|
|
76
|
-
const
|
|
77
|
-
for (const r of
|
|
78
|
-
r.data.length > 0 &&
|
|
79
|
-
return
|
|
135
|
+
}, [t]), [it, J] = ut(() => {
|
|
136
|
+
if (!ht) return;
|
|
137
|
+
const o = /* @__PURE__ */ new Map();
|
|
138
|
+
for (const r of t)
|
|
139
|
+
r.data.length > 0 && o.set(r.label, r.data[r.data.length - 1]);
|
|
140
|
+
return o;
|
|
80
141
|
}), [st, P] = ut(null);
|
|
81
|
-
|
|
82
|
-
const
|
|
83
|
-
if (
|
|
84
|
-
const
|
|
85
|
-
|
|
142
|
+
E(() => {
|
|
143
|
+
const o = () => {
|
|
144
|
+
if (R.current && A.current) {
|
|
145
|
+
const d = A.current.clientWidth, a = A.current.clientHeight;
|
|
146
|
+
R.current.resize(d, a), R.current.timeScale().fitContent();
|
|
86
147
|
}
|
|
87
|
-
}, r = A.current, l = r ? new ResizeObserver(
|
|
148
|
+
}, r = A.current, l = r ? new ResizeObserver(o) : null;
|
|
88
149
|
return r && l?.observe(r), () => {
|
|
89
150
|
r && l?.unobserve(r);
|
|
90
151
|
};
|
|
91
|
-
}, []),
|
|
92
|
-
if (!
|
|
93
|
-
const
|
|
152
|
+
}, []), E(() => {
|
|
153
|
+
if (!Z.current || q.current) return;
|
|
154
|
+
const o = gt(), r = ft(
|
|
94
155
|
"hsl(var(--foreground))",
|
|
95
156
|
"rgb(0, 0, 0)"
|
|
96
|
-
), l =
|
|
97
|
-
...
|
|
157
|
+
), l = Rt(Z.current, {
|
|
158
|
+
...o,
|
|
98
159
|
rightPriceScale: {
|
|
99
|
-
...
|
|
100
|
-
visible: !
|
|
160
|
+
...o.rightPriceScale || {},
|
|
161
|
+
visible: !O,
|
|
101
162
|
textColor: r
|
|
102
163
|
},
|
|
103
|
-
...
|
|
164
|
+
...j
|
|
104
165
|
});
|
|
105
|
-
return
|
|
106
|
-
l.remove(),
|
|
166
|
+
return R.current = l, q.current = !0, () => {
|
|
167
|
+
l.remove(), R.current = null, q.current = !1, h.current.clear();
|
|
107
168
|
};
|
|
108
|
-
}, [
|
|
109
|
-
const
|
|
110
|
-
if (!
|
|
111
|
-
const r =
|
|
112
|
-
formatter:
|
|
169
|
+
}, [O, j]), E(() => {
|
|
170
|
+
const o = R.current;
|
|
171
|
+
if (!o || t.length === 0) return;
|
|
172
|
+
const r = C === "time" ? dt(C, L) : dt(C), l = L.map((e) => e.value), {
|
|
173
|
+
formatter: d,
|
|
113
174
|
updateVisibleRange: a,
|
|
114
175
|
updateLastValues: f
|
|
115
|
-
} =
|
|
116
|
-
|
|
117
|
-
const
|
|
118
|
-
f(
|
|
119
|
-
const
|
|
120
|
-
|
|
176
|
+
} = Mt(l);
|
|
177
|
+
X.current = a, pt.current = f;
|
|
178
|
+
const b = t.filter((e) => e.data.length > 0).map((e) => e.data[e.data.length - 1].value);
|
|
179
|
+
f(b);
|
|
180
|
+
const S = gt();
|
|
181
|
+
o.applyOptions({
|
|
121
182
|
localization: {
|
|
122
|
-
...
|
|
183
|
+
...S.localization || {},
|
|
123
184
|
timeFormatter: r ? (
|
|
124
185
|
// biome-ignore lint/suspicious/noExplicitAny: External library type compatibility
|
|
125
|
-
((
|
|
186
|
+
((e) => r(parseFloat(e), void 0))
|
|
126
187
|
) : void 0
|
|
127
188
|
},
|
|
128
189
|
timeScale: {
|
|
129
|
-
...
|
|
190
|
+
...S.timeScale || {},
|
|
130
191
|
tickMarkFormatter: r ? (
|
|
131
192
|
// biome-ignore lint/suspicious/noExplicitAny: External library type compatibility
|
|
132
|
-
((
|
|
193
|
+
((e) => r(parseFloat(e), void 0))
|
|
133
194
|
) : void 0,
|
|
134
195
|
minBarSpacing: 0
|
|
135
196
|
}
|
|
136
197
|
});
|
|
137
|
-
const M = (L.length > 0 ? Math.min(...L.map((
|
|
198
|
+
const M = (L.length > 0 ? Math.min(...L.map((e) => e.value)) : 0) < 0, w = L.some((e) => e.value === 0), g = !M && w, i = t.length > 1, u = i || O, s = ft(
|
|
138
199
|
"hsl(var(--foreground))",
|
|
139
200
|
"rgb(0, 0, 0)"
|
|
140
201
|
);
|
|
141
|
-
|
|
202
|
+
o.applyOptions({
|
|
142
203
|
rightPriceScale: {
|
|
143
|
-
...
|
|
204
|
+
...S.rightPriceScale || {},
|
|
144
205
|
visible: !u,
|
|
145
206
|
textColor: s,
|
|
146
|
-
...
|
|
207
|
+
...g && {
|
|
147
208
|
scaleMargins: {
|
|
148
209
|
top: 0.3,
|
|
149
210
|
bottom: 0
|
|
@@ -151,85 +212,85 @@ function Yt({
|
|
|
151
212
|
}
|
|
152
213
|
}
|
|
153
214
|
});
|
|
154
|
-
const m = new Set(
|
|
155
|
-
for (const
|
|
156
|
-
if (!
|
|
157
|
-
const n =
|
|
158
|
-
n && (
|
|
215
|
+
const m = new Set(h.current.keys()), V = new Set(t.map((e) => e.label));
|
|
216
|
+
for (const e of m)
|
|
217
|
+
if (!V.has(e)) {
|
|
218
|
+
const n = h.current.get(e);
|
|
219
|
+
n && (o.removeSeries(n), h.current.delete(e));
|
|
159
220
|
}
|
|
160
|
-
const F =
|
|
161
|
-
let
|
|
162
|
-
for (let
|
|
163
|
-
const n =
|
|
164
|
-
let
|
|
221
|
+
const F = Lt(), H = [];
|
|
222
|
+
let z = 0;
|
|
223
|
+
for (let e = 0; e < t.length; e++) {
|
|
224
|
+
const n = t[e], tt = bt(e), Y = n.color || tt.line;
|
|
225
|
+
let T, I;
|
|
165
226
|
if (n.color)
|
|
166
227
|
if (n.topColor && n.bottomColor)
|
|
167
|
-
|
|
228
|
+
T = n.topColor, I = n.bottomColor;
|
|
168
229
|
else if (n.topColor) {
|
|
169
|
-
const c =
|
|
170
|
-
|
|
230
|
+
const c = $(Y);
|
|
231
|
+
T = n.topColor, I = c.bottomColor;
|
|
171
232
|
} else if (n.bottomColor)
|
|
172
|
-
|
|
233
|
+
T = $(Y).topColor, I = n.bottomColor;
|
|
173
234
|
else {
|
|
174
|
-
const c =
|
|
175
|
-
|
|
235
|
+
const c = $(Y);
|
|
236
|
+
T = c.topColor, I = c.bottomColor;
|
|
176
237
|
}
|
|
177
238
|
else
|
|
178
|
-
|
|
239
|
+
T = n.topColor || tt.top, I = n.bottomColor || tt.bottom;
|
|
179
240
|
if (n.data.length === 0) {
|
|
180
|
-
const c =
|
|
181
|
-
c && (
|
|
241
|
+
const c = h.current.get(n.label);
|
|
242
|
+
c && (o.removeSeries(c), h.current.delete(n.label));
|
|
182
243
|
continue;
|
|
183
244
|
}
|
|
184
|
-
const
|
|
185
|
-
i &&
|
|
245
|
+
const St = (n.data.length > 0 ? Math.min(...n.data.map((c) => c.value)) : 0) < 0, xt = n.data.some((c) => c.value === 0), yt = !St && xt, et = i ? z === 0 ? "right" : `scale-${z}` : "right";
|
|
246
|
+
i && H.push({
|
|
186
247
|
priceScaleId: et || "right",
|
|
187
|
-
shouldPreventNegativeAxis:
|
|
188
|
-
seriesIndex:
|
|
248
|
+
shouldPreventNegativeAxis: yt,
|
|
249
|
+
seriesIndex: z
|
|
189
250
|
});
|
|
190
|
-
let
|
|
191
|
-
|
|
192
|
-
lineColor:
|
|
193
|
-
topColor:
|
|
194
|
-
bottomColor:
|
|
251
|
+
let D = h.current.get(n.label);
|
|
252
|
+
D ? (D.applyOptions({
|
|
253
|
+
lineColor: Y,
|
|
254
|
+
topColor: T,
|
|
255
|
+
bottomColor: I,
|
|
195
256
|
priceScaleId: et,
|
|
196
257
|
priceFormat: {
|
|
197
258
|
type: "custom",
|
|
198
|
-
formatter:
|
|
259
|
+
formatter: d
|
|
199
260
|
}
|
|
200
|
-
}),
|
|
261
|
+
}), D.setData(
|
|
201
262
|
n.data.map((c) => ({
|
|
202
263
|
...c,
|
|
203
264
|
time: c.time
|
|
204
265
|
}))
|
|
205
|
-
)) : (
|
|
266
|
+
)) : (D = o.addAreaSeries({
|
|
206
267
|
...F,
|
|
207
|
-
lineColor:
|
|
208
|
-
topColor:
|
|
209
|
-
bottomColor:
|
|
268
|
+
lineColor: Y,
|
|
269
|
+
topColor: T,
|
|
270
|
+
bottomColor: I,
|
|
210
271
|
priceScaleId: et,
|
|
211
272
|
priceFormat: {
|
|
212
273
|
type: "custom",
|
|
213
|
-
formatter:
|
|
274
|
+
formatter: d
|
|
214
275
|
}
|
|
215
|
-
}),
|
|
276
|
+
}), D.setData(
|
|
216
277
|
n.data.map((c) => ({
|
|
217
278
|
...c,
|
|
218
279
|
time: c.time
|
|
219
280
|
}))
|
|
220
|
-
),
|
|
281
|
+
), h.current.set(n.label, D)), z++;
|
|
221
282
|
}
|
|
222
|
-
if (i &&
|
|
223
|
-
for (const
|
|
283
|
+
if (i && H.length > 0)
|
|
284
|
+
for (const e of H)
|
|
224
285
|
try {
|
|
225
|
-
const n =
|
|
286
|
+
const n = o.priceScale(e.priceScaleId);
|
|
226
287
|
n && n.applyOptions({
|
|
227
288
|
visible: !1,
|
|
228
289
|
autoScale: !0,
|
|
229
290
|
scaleMargins: {
|
|
230
291
|
top: 0.1,
|
|
231
292
|
bottom: 0.1,
|
|
232
|
-
...
|
|
293
|
+
...e.shouldPreventNegativeAxis && {
|
|
233
294
|
top: 0.3,
|
|
234
295
|
bottom: 0
|
|
235
296
|
}
|
|
@@ -242,20 +303,20 @@ function Yt({
|
|
|
242
303
|
});
|
|
243
304
|
} catch (n) {
|
|
244
305
|
console.warn(
|
|
245
|
-
`Failed to configure price scale ${
|
|
306
|
+
`Failed to configure price scale ${e.priceScaleId} for series ${e.seriesIndex}:`,
|
|
246
307
|
n
|
|
247
308
|
);
|
|
248
309
|
}
|
|
249
310
|
else if (!i)
|
|
250
311
|
try {
|
|
251
|
-
const
|
|
252
|
-
|
|
253
|
-
visible: !
|
|
312
|
+
const e = o.priceScale("right");
|
|
313
|
+
e && e.applyOptions({
|
|
314
|
+
visible: !O,
|
|
254
315
|
autoScale: !0,
|
|
255
316
|
scaleMargins: {
|
|
256
317
|
top: 0.1,
|
|
257
318
|
bottom: 0.1,
|
|
258
|
-
...
|
|
319
|
+
...g && {
|
|
259
320
|
top: 0.3,
|
|
260
321
|
bottom: 0
|
|
261
322
|
}
|
|
@@ -268,50 +329,50 @@ function Yt({
|
|
|
268
329
|
});
|
|
269
330
|
} catch {
|
|
270
331
|
}
|
|
271
|
-
const Q = new Set(
|
|
272
|
-
(lt.current ||
|
|
332
|
+
const Q = new Set(t.map((e) => e.label)), vt = Q.size !== W.current.size || [...Q].some((e) => !W.current.has(e)), Ct = L.length !== at.current;
|
|
333
|
+
(lt.current || vt || Ct || O) && (o.timeScale().fitContent(), lt.current = !1), W.current = Q, at.current = L.length;
|
|
273
334
|
const U = /* @__PURE__ */ new Map();
|
|
274
|
-
for (const
|
|
275
|
-
|
|
335
|
+
for (const e of t)
|
|
336
|
+
e.data.length > 0 && U.set(e.label, e.data[e.data.length - 1]);
|
|
276
337
|
J(U.size > 0 ? U : void 0);
|
|
277
|
-
}, [
|
|
278
|
-
const
|
|
279
|
-
if (!
|
|
280
|
-
const r =
|
|
338
|
+
}, [t, L, C, N, O]), E(() => {
|
|
339
|
+
const o = R.current;
|
|
340
|
+
if (!o || t.length === 0) return;
|
|
341
|
+
const r = t.length === 1;
|
|
281
342
|
let l;
|
|
282
|
-
for (const a of
|
|
343
|
+
for (const a of t)
|
|
283
344
|
if (a.data.length > 0) {
|
|
284
345
|
l = a.data[a.data.length - 1].time;
|
|
285
346
|
break;
|
|
286
347
|
}
|
|
287
348
|
if (!l) return;
|
|
288
|
-
const
|
|
289
|
-
const { time: f = l, seriesData:
|
|
290
|
-
if (!
|
|
291
|
-
const
|
|
292
|
-
for (const i of
|
|
293
|
-
i.data.length > 0 &&
|
|
294
|
-
if (J(
|
|
349
|
+
const d = (a) => {
|
|
350
|
+
const { time: f = l, seriesData: b, point: S } = a || {}, p = Array.from(h.current.values());
|
|
351
|
+
if (!S || !f) {
|
|
352
|
+
const g = /* @__PURE__ */ new Map();
|
|
353
|
+
for (const i of t)
|
|
354
|
+
i.data.length > 0 && g.set(i.label, i.data[i.data.length - 1]);
|
|
355
|
+
if (J(g.size > 0 ? g : void 0), r)
|
|
295
356
|
P(null);
|
|
296
357
|
else if (p[0] && l) {
|
|
297
|
-
const u =
|
|
358
|
+
const u = o.timeScale().timeToCoordinate(l), s = t[0];
|
|
298
359
|
if (s.data.length > 0) {
|
|
299
|
-
const m = s.data[s.data.length - 1].value,
|
|
300
|
-
u !== null &&
|
|
360
|
+
const m = s.data[s.data.length - 1].value, V = p[0].priceToCoordinate(m);
|
|
361
|
+
u !== null && V !== null && P({ x: u, y: V });
|
|
301
362
|
}
|
|
302
363
|
}
|
|
303
364
|
return;
|
|
304
365
|
}
|
|
305
366
|
const M = /* @__PURE__ */ new Map();
|
|
306
|
-
let
|
|
307
|
-
for (let
|
|
308
|
-
const i =
|
|
367
|
+
let w;
|
|
368
|
+
for (let g = 0; g < t.length; g++) {
|
|
369
|
+
const i = t[g], u = p[g];
|
|
309
370
|
if (!u) continue;
|
|
310
|
-
const s =
|
|
311
|
-
|
|
371
|
+
const s = b?.get(u), m = s && "value" in s ? s.value : void 0, V = i.data[i.data.length - 1], F = m !== void 0 ? m : V?.value ?? 0;
|
|
372
|
+
g === 0 && (w = F), M.set(i.label, { value: F, time: f });
|
|
312
373
|
}
|
|
313
|
-
if (J(M),
|
|
314
|
-
const i =
|
|
374
|
+
if (J(M), w !== void 0 && p[0]) {
|
|
375
|
+
const i = o.timeScale().timeToCoordinate(f), u = p[0].priceToCoordinate(w);
|
|
315
376
|
if (i !== null && u !== null) {
|
|
316
377
|
const s = A.current;
|
|
317
378
|
if (s) {
|
|
@@ -319,8 +380,8 @@ function Yt({
|
|
|
319
380
|
".LightweightChart"
|
|
320
381
|
);
|
|
321
382
|
if (m) {
|
|
322
|
-
const
|
|
323
|
-
P({ x:
|
|
383
|
+
const V = m.getBoundingClientRect(), F = s.getBoundingClientRect(), H = i + (V.left - F.left), z = u + (V.top - F.top);
|
|
384
|
+
P({ x: H, y: z });
|
|
324
385
|
} else
|
|
325
386
|
P({ x: i, y: u });
|
|
326
387
|
} else
|
|
@@ -330,105 +391,105 @@ function Yt({
|
|
|
330
391
|
} else
|
|
331
392
|
P(null);
|
|
332
393
|
};
|
|
333
|
-
return
|
|
334
|
-
const a = Array.from(
|
|
335
|
-
if (a[0] && l &&
|
|
336
|
-
const
|
|
337
|
-
|
|
394
|
+
return o.subscribeCrosshairMove(d), r || requestAnimationFrame(() => {
|
|
395
|
+
const a = Array.from(h.current.values());
|
|
396
|
+
if (a[0] && l && t[0]?.data.length > 0) {
|
|
397
|
+
const b = o.timeScale().timeToCoordinate(l), S = t[0].data[t[0].data.length - 1].value, p = a[0].priceToCoordinate(S);
|
|
398
|
+
b !== null && p !== null && P({ x: b, y: p });
|
|
338
399
|
}
|
|
339
400
|
}), () => {
|
|
340
|
-
|
|
401
|
+
o.unsubscribeCrosshairMove(d);
|
|
341
402
|
};
|
|
342
|
-
}, [
|
|
343
|
-
const
|
|
344
|
-
if (!
|
|
345
|
-
const r =
|
|
403
|
+
}, [t]), E(() => {
|
|
404
|
+
const o = R.current;
|
|
405
|
+
if (!o || t.length === 0) return;
|
|
406
|
+
const r = o.timeScale(), l = Math.max(...t.map((a) => a.data.length)), d = () => {
|
|
346
407
|
if (l === 0) return;
|
|
347
408
|
const a = r.getVisibleLogicalRange();
|
|
348
409
|
if (!a) return;
|
|
349
410
|
const f = {
|
|
350
411
|
from: 0,
|
|
351
412
|
to: l - 1
|
|
352
|
-
},
|
|
353
|
-
if (
|
|
354
|
-
const
|
|
355
|
-
for (const s of
|
|
356
|
-
for (let m =
|
|
413
|
+
}, b = typeof a.from == "number" ? a.from : 0, S = typeof a.to == "number" ? a.to : l - 1;
|
|
414
|
+
if (X.current) {
|
|
415
|
+
const g = Math.max(0, Math.floor(b)), i = Math.min(l - 1, Math.ceil(S)), u = [];
|
|
416
|
+
for (const s of t)
|
|
417
|
+
for (let m = g; m <= i && m < s.data.length; m++)
|
|
357
418
|
u.push(s.data[m].value);
|
|
358
|
-
u.length > 0 &&
|
|
419
|
+
u.length > 0 && X.current(u);
|
|
359
420
|
}
|
|
360
421
|
const p = 0.01;
|
|
361
422
|
let M = !1;
|
|
362
|
-
const
|
|
363
|
-
|
|
423
|
+
const w = { ...a };
|
|
424
|
+
b < f.from - p && (w.from = f.from, M = !0), S > f.to + p && (w.to = f.to, M = !0), M && r.setVisibleLogicalRange(w);
|
|
364
425
|
};
|
|
365
|
-
return r.subscribeVisibleLogicalRangeChange(
|
|
426
|
+
return r.subscribeVisibleLogicalRangeChange(d), () => {
|
|
366
427
|
r.unsubscribeVisibleLogicalRangeChange(
|
|
367
|
-
|
|
428
|
+
d
|
|
368
429
|
);
|
|
369
430
|
};
|
|
370
|
-
}, [
|
|
371
|
-
const
|
|
372
|
-
if (
|
|
373
|
-
const
|
|
374
|
-
for (const f of
|
|
375
|
-
const
|
|
376
|
-
...
|
|
431
|
+
}, [t]), E(() => {
|
|
432
|
+
const o = R.current, r = Array.from(h.current.values()), l = [];
|
|
433
|
+
if (o && r.length > 0 && B) {
|
|
434
|
+
const d = Pt(), a = r[0];
|
|
435
|
+
for (const f of B) {
|
|
436
|
+
const b = new Ft(o, a, f.xCoordinate, {
|
|
437
|
+
...d,
|
|
377
438
|
...f.options || {}
|
|
378
439
|
});
|
|
379
|
-
a.attachPrimitive(
|
|
440
|
+
a.attachPrimitive(b), l.push(b);
|
|
380
441
|
}
|
|
381
442
|
}
|
|
382
443
|
return () => {
|
|
383
444
|
if (r.length > 0) {
|
|
384
|
-
const
|
|
445
|
+
const d = r[0];
|
|
385
446
|
for (const a of l)
|
|
386
|
-
|
|
447
|
+
d.detachPrimitive(a);
|
|
387
448
|
}
|
|
388
449
|
};
|
|
389
|
-
}, [
|
|
390
|
-
const K =
|
|
391
|
-
if (K &&
|
|
392
|
-
const
|
|
393
|
-
if (
|
|
394
|
-
return
|
|
450
|
+
}, [B]);
|
|
451
|
+
const K = t.length === 1, ct = ot.useMemo(() => {
|
|
452
|
+
if (K && t.length > 0) {
|
|
453
|
+
const o = t[0];
|
|
454
|
+
if (o.data.length > 0)
|
|
455
|
+
return o.data[o.data.length - 1];
|
|
395
456
|
}
|
|
396
|
-
}, [K,
|
|
397
|
-
return /* @__PURE__ */
|
|
457
|
+
}, [K, t]);
|
|
458
|
+
return /* @__PURE__ */ _(
|
|
398
459
|
"div",
|
|
399
460
|
{
|
|
400
461
|
ref: A,
|
|
401
462
|
className: mt(
|
|
402
463
|
"relative z-[1] w-full h-full overflow-hidden p-0",
|
|
403
|
-
|
|
464
|
+
G
|
|
404
465
|
),
|
|
405
466
|
children: [
|
|
406
|
-
K && ct && /* @__PURE__ */
|
|
407
|
-
|
|
467
|
+
K && ct && /* @__PURE__ */ y(
|
|
468
|
+
Nt,
|
|
408
469
|
{
|
|
409
470
|
point: ct,
|
|
410
|
-
xMeasureUnit:
|
|
411
|
-
yMeasureUnit:
|
|
471
|
+
xMeasureUnit: C,
|
|
472
|
+
yMeasureUnit: N,
|
|
412
473
|
decimals: nt
|
|
413
474
|
}
|
|
414
475
|
),
|
|
415
|
-
it && st && /* @__PURE__ */
|
|
416
|
-
|
|
476
|
+
it && st && /* @__PURE__ */ y(
|
|
477
|
+
At,
|
|
417
478
|
{
|
|
418
479
|
points: it,
|
|
419
|
-
xMeasureUnit:
|
|
420
|
-
yMeasureUnit:
|
|
421
|
-
series:
|
|
480
|
+
xMeasureUnit: C,
|
|
481
|
+
yMeasureUnit: N,
|
|
482
|
+
series: t,
|
|
422
483
|
position: st,
|
|
423
484
|
containerRef: A,
|
|
424
485
|
decimals: nt
|
|
425
486
|
}
|
|
426
487
|
),
|
|
427
|
-
|
|
428
|
-
/* @__PURE__ */
|
|
488
|
+
v && /* @__PURE__ */ y(It, { series: t, onUnselect: k }),
|
|
489
|
+
/* @__PURE__ */ y(
|
|
429
490
|
"div",
|
|
430
491
|
{
|
|
431
|
-
ref:
|
|
492
|
+
ref: Z,
|
|
432
493
|
className: "LightweightChart w-full h-full overflow-hidden"
|
|
433
494
|
}
|
|
434
495
|
)
|
|
@@ -436,41 +497,41 @@ function Yt({
|
|
|
436
497
|
}
|
|
437
498
|
);
|
|
438
499
|
}
|
|
439
|
-
function
|
|
440
|
-
series:
|
|
441
|
-
onUnselect:
|
|
500
|
+
function It({
|
|
501
|
+
series: t,
|
|
502
|
+
onUnselect: G
|
|
442
503
|
}) {
|
|
443
|
-
return /* @__PURE__ */
|
|
444
|
-
const
|
|
445
|
-
return /* @__PURE__ */
|
|
504
|
+
return /* @__PURE__ */ y("div", { className: "absolute top-0 left-2 z-[10] flex flex-wrap gap-2", children: t.map((v, k) => {
|
|
505
|
+
const C = bt(k), N = v.color || C.line, j = v.data.length === 0;
|
|
506
|
+
return /* @__PURE__ */ _(
|
|
446
507
|
"div",
|
|
447
508
|
{
|
|
448
509
|
className: mt(
|
|
449
510
|
"flex items-center gap-1.5 px-2 py-1 bg-background/80 backdrop-blur-sm rounded border border-border",
|
|
450
|
-
|
|
511
|
+
j && "opacity-50"
|
|
451
512
|
),
|
|
452
513
|
children: [
|
|
453
|
-
/* @__PURE__ */
|
|
514
|
+
/* @__PURE__ */ y(
|
|
454
515
|
"div",
|
|
455
516
|
{
|
|
456
517
|
className: "w-3 h-3 rounded-sm",
|
|
457
|
-
style: { backgroundColor:
|
|
518
|
+
style: { backgroundColor: N }
|
|
458
519
|
}
|
|
459
520
|
),
|
|
460
|
-
/* @__PURE__ */
|
|
461
|
-
|
|
462
|
-
|
|
521
|
+
/* @__PURE__ */ _("span", { className: "text-[10px] sm:text-xs font-medium text-foreground", children: [
|
|
522
|
+
v.label,
|
|
523
|
+
j && " (no data)"
|
|
463
524
|
] }),
|
|
464
|
-
|
|
525
|
+
G && /* @__PURE__ */ y(
|
|
465
526
|
"button",
|
|
466
527
|
{
|
|
467
528
|
type: "button",
|
|
468
|
-
onClick: (
|
|
469
|
-
|
|
529
|
+
onClick: (B) => {
|
|
530
|
+
B.stopPropagation(), G(v.label);
|
|
470
531
|
},
|
|
471
532
|
className: "ml-1 flex items-center justify-center w-4 h-4 rounded-sm hover:bg-muted transition-colors cursor-pointer",
|
|
472
|
-
"aria-label": `Remove ${
|
|
473
|
-
children: /* @__PURE__ */
|
|
533
|
+
"aria-label": `Remove ${v.label}`,
|
|
534
|
+
children: /* @__PURE__ */ _(
|
|
474
535
|
"svg",
|
|
475
536
|
{
|
|
476
537
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -485,9 +546,9 @@ function Ft({
|
|
|
485
546
|
className: "text-muted-foreground hover:text-foreground",
|
|
486
547
|
"aria-hidden": "true",
|
|
487
548
|
children: [
|
|
488
|
-
/* @__PURE__ */
|
|
489
|
-
/* @__PURE__ */
|
|
490
|
-
/* @__PURE__ */
|
|
549
|
+
/* @__PURE__ */ y("title", { children: "Close" }),
|
|
550
|
+
/* @__PURE__ */ y("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
|
|
551
|
+
/* @__PURE__ */ y("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
|
|
491
552
|
]
|
|
492
553
|
}
|
|
493
554
|
)
|
|
@@ -495,11 +556,12 @@ function Ft({
|
|
|
495
556
|
)
|
|
496
557
|
]
|
|
497
558
|
},
|
|
498
|
-
|
|
559
|
+
v.label
|
|
499
560
|
);
|
|
500
561
|
}) });
|
|
501
562
|
}
|
|
502
563
|
export {
|
|
503
|
-
|
|
504
|
-
|
|
564
|
+
rt as DEFAULT_SERIES_COLORS,
|
|
565
|
+
qt as Graph,
|
|
566
|
+
bt as getSeriesColorPalette
|
|
505
567
|
};
|