@gearbox-protocol/ui-kit 4.0.0-next.66 → 4.0.0-next.68
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/esm/components/graph/graph.js +6 -1
- package/dist/types/components/base/history-chart/history-chart.d.ts +6 -1
- package/dist/types/components/base/manage-pane/manage-pane.d.ts +10 -10
- package/dist/types/components/graph/graph-view.d.ts +1 -1
- package/dist/types/components/graph/graph.d.ts +3 -2
- 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
|
};
|
|
@@ -719,7 +719,12 @@ function to({
|
|
|
719
719
|
...p.options || {}
|
|
720
720
|
};
|
|
721
721
|
m.color && (m.color = re(m.color, m.color));
|
|
722
|
-
const y = new _t(
|
|
722
|
+
const y = new _t(
|
|
723
|
+
t,
|
|
724
|
+
a,
|
|
725
|
+
p.xCoordinate,
|
|
726
|
+
m
|
|
727
|
+
);
|
|
723
728
|
a.attachPrimitive(y), r.push(y);
|
|
724
729
|
}
|
|
725
730
|
}
|
|
@@ -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;
|
|
@@ -2,15 +2,15 @@ import { default as React } from 'react';
|
|
|
2
2
|
import { TitleText } from '../text';
|
|
3
3
|
import { ManagePaneTest } from './constants';
|
|
4
4
|
export { ManagePaneTest };
|
|
5
|
-
export interface ManagePaneTabProps {
|
|
6
|
-
readonly id:
|
|
5
|
+
export interface ManagePaneTabProps<T extends string = string> {
|
|
6
|
+
readonly id: T;
|
|
7
7
|
readonly title: TitleText;
|
|
8
8
|
readonly disabled?: boolean;
|
|
9
9
|
/** Content is selectable (e.g. from the dropdown) but not shown in the segment. */
|
|
10
10
|
readonly hidden?: boolean;
|
|
11
11
|
readonly children?: React.ReactNode;
|
|
12
12
|
}
|
|
13
|
-
export declare function ManagePaneTab(_props: ManagePaneTabProps): null;
|
|
13
|
+
export declare function ManagePaneTab<T extends string>(_props: ManagePaneTabProps<T>): null;
|
|
14
14
|
export interface ManagePaneTabDropdownItem {
|
|
15
15
|
readonly id: string;
|
|
16
16
|
readonly title: React.ReactNode;
|
|
@@ -20,20 +20,20 @@ export interface ManagePaneTabDropdownProps {
|
|
|
20
20
|
readonly items: ReadonlyArray<ManagePaneTabDropdownItem>;
|
|
21
21
|
}
|
|
22
22
|
export declare function ManagePaneTabDropdown(_props: ManagePaneTabDropdownProps): null;
|
|
23
|
-
export interface ManagePaneActionTabProps {
|
|
24
|
-
readonly id:
|
|
23
|
+
export interface ManagePaneActionTabProps<T extends string = string> {
|
|
24
|
+
readonly id: T;
|
|
25
25
|
readonly title: TitleText;
|
|
26
26
|
/** Fires without changing the active tab (e.g. "My positions"). */
|
|
27
27
|
readonly onClick?: () => void;
|
|
28
28
|
/** When set, a click opens this content in a dialog instead of switching tabs. */
|
|
29
29
|
readonly children?: React.ReactNode;
|
|
30
30
|
}
|
|
31
|
-
export declare function ManagePaneActionTab(_props: ManagePaneActionTabProps): null;
|
|
32
|
-
export interface ManagePaneProps {
|
|
31
|
+
export declare function ManagePaneActionTab<T extends string>(_props: ManagePaneActionTabProps<T>): null;
|
|
32
|
+
export interface ManagePaneProps<T extends string> {
|
|
33
33
|
readonly children: React.ReactNode;
|
|
34
34
|
/** Controlled active tab — the screen owns it (usually `?operation=`). */
|
|
35
|
-
readonly activeTab:
|
|
36
|
-
readonly onTabChange: (id:
|
|
35
|
+
readonly activeTab: T;
|
|
36
|
+
readonly onTabChange: (id: T) => void;
|
|
37
37
|
readonly header?: React.ReactNode;
|
|
38
38
|
readonly footer?: React.ReactNode;
|
|
39
39
|
/** Rendered to the right of the tabs (e.g. the settings button). */
|
|
@@ -45,7 +45,7 @@ export interface ManagePaneProps {
|
|
|
45
45
|
* dropdown and actions) above one card that shows the active tab's content.
|
|
46
46
|
* Controlled only — no hash state of its own.
|
|
47
47
|
*/
|
|
48
|
-
export declare function ManagePane({ children, activeTab, onTabChange, header, footer, actions, testId, }: ManagePaneProps): React.ReactElement;
|
|
48
|
+
export declare function ManagePane<T extends string>({ children, activeTab, onTabChange, header, footer, actions, testId, }: ManagePaneProps<T>): React.ReactElement;
|
|
49
49
|
/** Body shown in place of a dialog when the tab has nothing to act on (no position, no wallet). */
|
|
50
50
|
export declare function ManagePaneMessage({ children, }: {
|
|
51
51
|
readonly children: React.ReactNode;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ChartOptions, DeepPartial
|
|
1
|
+
import { ChartOptions, DeepPartial } from 'lightweight-charts';
|
|
2
2
|
import { Point, YMeasureUnits } from './formatters';
|
|
3
3
|
import { GraphTooltipProps } from './graph-tooltip';
|
|
4
4
|
import { PriceLineConfig, PriceZoneConfig } from './graph-vocabulary';
|
|
@@ -90,7 +90,8 @@ export interface GraphProps {
|
|
|
90
90
|
xMeasureUnit?: GraphTooltipProps["xMeasureUnit"];
|
|
91
91
|
optionsOverrides?: DeepPartial<ChartOptions>;
|
|
92
92
|
verticalLineOptions?: Array<{
|
|
93
|
-
|
|
93
|
+
/** Same scale as `GraphPoint.timestamp`; branded for the chart internally. */
|
|
94
|
+
xCoordinate: number;
|
|
94
95
|
options?: VerticalLineOptions;
|
|
95
96
|
}>;
|
|
96
97
|
/**
|