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