@gearbox-protocol/ui-kit 4.0.0-next.66 → 4.0.0-next.67
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/base/history-chart/history-chart.cjs +1 -1
- package/dist/esm/components/base/history-chart/history-chart.js +22 -23
- package/dist/types/components/base/history-chart/history-chart.d.ts +6 -1
- package/dist/types/components/graph/graph-view.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("react/jsx-runtime"),j=require("@gearbox-protocol/sdk/model"),A=require("react"),w=require("../text/use-title-text.cjs"),M=require("../../trading-view/trading-view.cjs"),E=require("../../typed-intl/index.cjs"),_=require("./constants.cjs"),G=j.CHART_RANGES,L={"1d":"1D","1w":"7D","1m":"1M","1y":"1Y",max:"MAX"};function O({data:t,range:e,onRange:a,isLoading:S=!1,error:x,yMeasureUnit:c="none",height:v,seriesTitles:l,priceLines:p,zones:y,showCurrentValue:C=!1,yScaleMin:T,title:h,trailing:b,emptyMessage:q,dualYAxis:R}){const f=E.useIntlTyped(),H=w.useTitleText(),r=A.useMemo(()=>Array.isArray(c)?c:void 0,[c]),d=r!=null&&new Set(r).size>1,u=R??d,m=r?.[0],I=A.useMemo(()=>{const i=(n,o)=>{if(!u)return n;if(d&&r!=null&&m!=null){const s=r[o]??m;return{...n,priceScaleId:s===m?"left":"right"}}return{...n,priceScaleId:o===0?"left":"right"}};if(t)return(Array.isArray(t)?t:[t]).map((o,s)=>i(D(l)(o),s));if(l)return Object.entries(l).map(([n,o],s)=>i({id:n,title:o,data:[]},s))},[t,l,d,u,m,r]);return g.jsx("div",{"data-testid":_.HistoryChartTest.root,children:g.jsx(M.TradingView,{data:I,isLoading:S,error:x?f.formatMessage({messageId:"components.historyChart.error"}):void 0,emptyMessage:q??f.formatMessage({messageId:"components.historyChart.empty"}),dualYAxis:u,useSharedPriceScale:!u,yMeasureUnit:c,height:v,rangeList:G.map(i=>({value:i,label:L[i]})),range:e,setRange:a,priceLineOptions:p?[...p]:void 0,zoneOptions:y?[...y]:void 0,showCurrentValue:C,yScaleMin:T,disableZoom:!0,title:h!=null?H(h):void 0,trailing:b})})}function D(t){return e=>({id:e.metric,title:t?.[e.metric]??e.metric,data:e.points.map(a=>({time:a.timestamp,value:a.value}))})}exports.HistoryChartTest=_.HistoryChartTest;exports.HistoryChart=O;
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { jsx as y } from "react/jsx-runtime";
|
|
2
|
-
import { CHART_RANGES as
|
|
2
|
+
import { CHART_RANGES as w } from "@gearbox-protocol/sdk/model";
|
|
3
3
|
import { useMemo as S } from "react";
|
|
4
|
-
import { useTitleText as
|
|
5
|
-
import { TradingView as
|
|
6
|
-
import { useIntlTyped as
|
|
7
|
-
import { HistoryChartTest as
|
|
8
|
-
const
|
|
4
|
+
import { useTitleText as D } from "../text/use-title-text.js";
|
|
5
|
+
import { TradingView as H } from "../../trading-view/trading-view.js";
|
|
6
|
+
import { useIntlTyped as M } from "../../typed-intl/index.js";
|
|
7
|
+
import { HistoryChartTest as N } from "./constants.js";
|
|
8
|
+
const O = w, T = {
|
|
9
9
|
"1d": "1D",
|
|
10
10
|
"1w": "7D",
|
|
11
11
|
"1m": "1M",
|
|
12
12
|
"1y": "1Y",
|
|
13
13
|
max: "MAX"
|
|
14
14
|
};
|
|
15
|
-
function
|
|
15
|
+
function Z({
|
|
16
16
|
data: t,
|
|
17
17
|
range: r,
|
|
18
18
|
onRange: a,
|
|
@@ -27,12 +27,13 @@ function X({
|
|
|
27
27
|
yScaleMin: I,
|
|
28
28
|
title: A,
|
|
29
29
|
trailing: R,
|
|
30
|
-
|
|
30
|
+
emptyMessage: E,
|
|
31
|
+
dualYAxis: G
|
|
31
32
|
}) {
|
|
32
|
-
const h =
|
|
33
|
+
const h = M(), L = D(), o = S(
|
|
33
34
|
() => Array.isArray(m) ? m : void 0,
|
|
34
35
|
[m]
|
|
35
|
-
), p = o != null && new Set(o).size > 1, l =
|
|
36
|
+
), p = o != null && new Set(o).size > 1, l = G ?? p, d = o?.[0], b = S(() => {
|
|
36
37
|
const n = (e, i) => {
|
|
37
38
|
if (!l) return e;
|
|
38
39
|
if (p && o != null && d != null) {
|
|
@@ -49,7 +50,7 @@ function X({
|
|
|
49
50
|
};
|
|
50
51
|
if (t)
|
|
51
52
|
return (Array.isArray(t) ? t : [t]).map(
|
|
52
|
-
(i, s) => n(
|
|
53
|
+
(i, s) => n(Y(c)(i), s)
|
|
53
54
|
);
|
|
54
55
|
if (c)
|
|
55
56
|
return Object.entries(c).map(
|
|
@@ -63,22 +64,20 @@ function X({
|
|
|
63
64
|
)
|
|
64
65
|
);
|
|
65
66
|
}, [t, c, p, l, d, o]);
|
|
66
|
-
return /* @__PURE__ */ y("div", { "data-testid":
|
|
67
|
-
|
|
67
|
+
return /* @__PURE__ */ y("div", { "data-testid": N.root, children: /* @__PURE__ */ y(
|
|
68
|
+
H,
|
|
68
69
|
{
|
|
69
|
-
data:
|
|
70
|
+
data: b,
|
|
70
71
|
isLoading: g,
|
|
71
72
|
error: v ? h.formatMessage({ messageId: "components.historyChart.error" }) : void 0,
|
|
72
|
-
emptyMessage: h.formatMessage({
|
|
73
|
-
messageId: "components.historyChart.empty"
|
|
74
|
-
}),
|
|
73
|
+
emptyMessage: E ?? h.formatMessage({ messageId: "components.historyChart.empty" }),
|
|
75
74
|
dualYAxis: l,
|
|
76
75
|
useSharedPriceScale: !l,
|
|
77
76
|
yMeasureUnit: m,
|
|
78
77
|
height: x,
|
|
79
|
-
rangeList:
|
|
78
|
+
rangeList: O.map((n) => ({
|
|
80
79
|
value: n,
|
|
81
|
-
label:
|
|
80
|
+
label: T[n]
|
|
82
81
|
})),
|
|
83
82
|
range: r,
|
|
84
83
|
setRange: a,
|
|
@@ -87,12 +86,12 @@ function X({
|
|
|
87
86
|
showCurrentValue: C,
|
|
88
87
|
yScaleMin: I,
|
|
89
88
|
disableZoom: !0,
|
|
90
|
-
title: A != null ?
|
|
89
|
+
title: A != null ? L(A) : void 0,
|
|
91
90
|
trailing: R
|
|
92
91
|
}
|
|
93
92
|
) });
|
|
94
93
|
}
|
|
95
|
-
function
|
|
94
|
+
function Y(t) {
|
|
96
95
|
return (r) => ({
|
|
97
96
|
id: r.metric,
|
|
98
97
|
title: t?.[r.metric] ?? r.metric,
|
|
@@ -103,6 +102,6 @@ function T(t) {
|
|
|
103
102
|
});
|
|
104
103
|
}
|
|
105
104
|
export {
|
|
106
|
-
|
|
107
|
-
|
|
105
|
+
Z as HistoryChart,
|
|
106
|
+
N as HistoryChartTest
|
|
108
107
|
};
|
|
@@ -47,6 +47,11 @@ export interface HistoryChartProps {
|
|
|
47
47
|
readonly title?: TitleText;
|
|
48
48
|
/** Controls to the left of the range dropdown (e.g. leverage chips). */
|
|
49
49
|
readonly trailing?: React.ReactNode;
|
|
50
|
+
/**
|
|
51
|
+
* Replaces the default "No data" placeholder when the range holds no points,
|
|
52
|
+
* e.g. a screen that knows the series is still being indexed.
|
|
53
|
+
*/
|
|
54
|
+
readonly emptyMessage?: React.ReactNode;
|
|
50
55
|
/**
|
|
51
56
|
* Force a second Y-axis. When omitted, the chart splits axes only if
|
|
52
57
|
* `yMeasureUnit` lists more than one distinct unit. Same-unit series share
|
|
@@ -59,4 +64,4 @@ export interface HistoryChartProps {
|
|
|
59
64
|
* below the frame, tooltips, optional reference lines and zones. Takes the SDK's
|
|
60
65
|
* a `HistorySeries` as it comes — points are mapped 1:1, no fetching.
|
|
61
66
|
*/
|
|
62
|
-
export declare function HistoryChart({ data, range, onRange, isLoading, error, yMeasureUnit, height, seriesTitles, priceLines, zones, showCurrentValue, yScaleMin, title, trailing, dualYAxis: dualYAxisProp, }: HistoryChartProps): React.ReactElement;
|
|
67
|
+
export declare function HistoryChart({ data, range, onRange, isLoading, error, yMeasureUnit, height, seriesTitles, priceLines, zones, showCurrentValue, yScaleMin, title, trailing, emptyMessage, dualYAxis: dualYAxisProp, }: HistoryChartProps): React.ReactElement;
|