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