@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.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("react/jsx-runtime"),I=require("@gearbox-protocol/sdk/model"),A=require("react"),j=require("../text/use-title-text.cjs"),w=require("../../trading-view/trading-view.cjs"),M=require("../../typed-intl/index.cjs"),_=require("./constants.cjs"),E=I.CHART_RANGES,G={"1d":"1D","1w":"7D","1m":"1M","1y":"1Y",max:"MAX"};function L({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,dualYAxis:q}){const f=M.useIntlTyped(),R=j.useTitleText(),r=A.useMemo(()=>Array.isArray(c)?c:void 0,[c]),d=r!=null&&new Set(r).size>1,u=q??d,m=r?.[0],H=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(O(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(w.TradingView,{data:H,isLoading:S,error:x?f.formatMessage({messageId:"components.historyChart.error"}):void 0,emptyMessage:f.formatMessage({messageId:"components.historyChart.empty"}),dualYAxis:u,useSharedPriceScale:!u,yMeasureUnit:c,height:v,rangeList:E.map(i=>({value:i,label:G[i]})),range:e,setRange:a,priceLineOptions:p?[...p]:void 0,zoneOptions:y?[...y]:void 0,showCurrentValue:C,yScaleMin:T,disableZoom:!0,title:h!=null?R(h):void 0,trailing:b})})}function O(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=L;
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 b } from "@gearbox-protocol/sdk/model";
2
+ import { CHART_RANGES as w } from "@gearbox-protocol/sdk/model";
3
3
  import { useMemo as S } from "react";
4
- import { useTitleText as w } from "../text/use-title-text.js";
5
- import { TradingView as D } from "../../trading-view/trading-view.js";
6
- import { useIntlTyped as H } from "../../typed-intl/index.js";
7
- import { HistoryChartTest as M } from "./constants.js";
8
- const N = b, O = {
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 X({
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
- dualYAxis: E
30
+ emptyMessage: E,
31
+ dualYAxis: G
31
32
  }) {
32
- const h = H(), G = w(), o = S(
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 = E ?? p, d = o?.[0], L = S(() => {
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(T(c)(i), s)
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": M.root, children: /* @__PURE__ */ y(
67
- D,
67
+ return /* @__PURE__ */ y("div", { "data-testid": N.root, children: /* @__PURE__ */ y(
68
+ H,
68
69
  {
69
- data: L,
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: N.map((n) => ({
78
+ rangeList: O.map((n) => ({
80
79
  value: n,
81
- label: O[n]
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 ? G(A) : void 0,
89
+ title: A != null ? L(A) : void 0,
91
90
  trailing: R
92
91
  }
93
92
  ) });
94
93
  }
95
- function T(t) {
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
- X as HistoryChart,
107
- M as HistoryChartTest
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;
@@ -29,7 +29,7 @@ export interface GraphViewProps extends React.HTMLAttributes<HTMLDivElement>, Va
29
29
  /**
30
30
  * Optional empty state message
31
31
  */
32
- emptyMessage?: string;
32
+ emptyMessage?: React.ReactNode;
33
33
  /**
34
34
  * Optional error message
35
35
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/ui-kit",
3
- "version": "4.0.0-next.66",
3
+ "version": "4.0.0-next.67",
4
4
  "description": "Internal UI components",
5
5
  "repository": {
6
6
  "type": "git",