@gearbox-protocol/permissionless-ui 1.17.8 → 1.17.9
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/graph/formatters.cjs +1 -1
- package/dist/cjs/components/graph/graph-current-value.cjs +1 -1
- package/dist/cjs/components/graph/graph-tooltip.cjs +1 -1
- package/dist/cjs/components/graph/graph.cjs +1 -1
- package/dist/cjs/components/trading-view/trading-view.cjs +1 -1
- package/dist/esm/components/graph/formatters.js +1 -1
- package/dist/esm/components/graph/graph-current-value.js +14 -13
- package/dist/esm/components/graph/graph-tooltip.js +36 -35
- package/dist/esm/components/graph/graph.js +49 -46
- package/dist/esm/components/trading-view/trading-view.js +30 -28
- package/dist/types/components/graph/graph-current-value.d.ts +6 -1
- package/dist/types/components/graph/graph-tooltip.d.ts +6 -1
- package/dist/types/components/graph/graph.d.ts +6 -1
- package/dist/types/components/trading-view/trading-view.d.ts +6 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("luxon"),s=require("../../utils/format-number.cjs"),{MIN_DISPLAY_THRESHOLD:u,MAX_EXPONENTIAL_THRESHOLD:T}=s.FORMAT_CONSTANTS,E=(t,e,r="full")=>{if(s.isBelowDisplayThreshold(t))return e?`<${u}${e}`:`<${u}`;if(t===0)return e?`0${e}`:"0";const n=s.formatNumberWithSuffix(t,{maxExponentialThreshold:T,minimumFractionDigits:0,maximumFractionDigits:r==="short"?1:0,format:r,adaptiveDecimals:r==="short"});return e?`${n}${e}`:n},A=2,x=(t,e)=>{if(s.isBelowDisplayThreshold(t))return e?`<${u}${e}`:`<${u}`;if(t===0)return e?`0${e}`:"0";const r=s.toSignificantDigits(t,A);return e?`${r}${e}`:r},I=4,_=t=>{if(s.isBelowDisplayThreshold(t))return`<${u}`;if(t===0)return"0";const e=Math.round(t),r=Math.abs(t-e);return r>0&&r<.01?t.toFixed(12).replace(/0+$/,"").replace(/\.$/,""):s.toSignificantDigits(t,I)},H=(t,e)=>{if(s.isBelowDisplayThreshold(t))return e?`<${u} ${e}`:`<${u}`;if(t===0)return e?`0 ${e}`:"0";const r=Number.isInteger(t),n=Math.abs(t),m=r&&n>=1e3,l=Math.round(t),h=Math.abs(t-l);if(h>0&&h<.01&&!m){const S=t.toFixed(12).replace(/0+$/,"").replace(/\.$/,"");return e?`${S} ${e}`:S}const D=s.formatNumberWithSuffix(t,{maxExponentialThreshold:T,minimumFractionDigits:r?0:2,maximumFractionDigits:m?1:r?0:2,format:m?"short":"full",adaptiveDecimals:m});return e?`${D} ${e}`:D},M={"%":x,$:E,token:H,none:_},R=t=>M[t]||M.token;function O(t,e,r=
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("luxon"),s=require("../../utils/format-number.cjs"),{MIN_DISPLAY_THRESHOLD:u,MAX_EXPONENTIAL_THRESHOLD:T}=s.FORMAT_CONSTANTS,E=(t,e,r="full")=>{if(s.isBelowDisplayThreshold(t))return e?`<${u}${e}`:`<${u}`;if(t===0)return e?`0${e}`:"0";const n=s.formatNumberWithSuffix(t,{maxExponentialThreshold:T,minimumFractionDigits:0,maximumFractionDigits:r==="short"?1:0,format:r,adaptiveDecimals:r==="short"});return e?`${n}${e}`:n},A=2,x=(t,e)=>{if(s.isBelowDisplayThreshold(t))return e?`<${u}${e}`:`<${u}`;if(t===0)return e?`0${e}`:"0";const r=s.toSignificantDigits(t,A);return e?`${r}${e}`:r},I=4,_=t=>{if(s.isBelowDisplayThreshold(t))return`<${u}`;if(t===0)return"0";const e=Math.round(t),r=Math.abs(t-e);return r>0&&r<.01?t.toFixed(12).replace(/0+$/,"").replace(/\.$/,""):s.toSignificantDigits(t,I)},H=(t,e)=>{if(s.isBelowDisplayThreshold(t))return e?`<${u} ${e}`:`<${u}`;if(t===0)return e?`0 ${e}`:"0";const r=Number.isInteger(t),n=Math.abs(t),m=r&&n>=1e3,l=Math.round(t),h=Math.abs(t-l);if(h>0&&h<.01&&!m){const S=t.toFixed(12).replace(/0+$/,"").replace(/\.$/,"");return e?`${S} ${e}`:S}const D=s.formatNumberWithSuffix(t,{maxExponentialThreshold:T,minimumFractionDigits:r?0:2,maximumFractionDigits:m?1:r?0:2,format:m?"short":"full",adaptiveDecimals:m});return e?`${D} ${e}`:D},M={"%":x,$:E,token:H,none:_},R=t=>M[t]||M.token;function O(t,e,r=4){if(t===0)return e?`0 ${e}`:"0";const n=t.toLocaleString("en-US",{minimumFractionDigits:0,maximumFractionDigits:r});return e?`${n} ${e}`:n}function X(t,e){let r=t.length>0?Math.min(...t):0,n=t.length>0?Math.max(...t):0,m=[];const l=()=>{const a=n-r,i=(r+n)/2;let o=1,c="";i>=1e9?(o=1e9,c="B"):i>=1e6?(o=1e6,c="M"):i>=1e3&&(o=1e3,c="K");const f=a/10/o;let d=1;if(f>0){const N=Math.floor(Math.log10(f));d=Math.max(1,-N),d=Math.min(d,4)}return{scale:o,suffix:c,decimals:d}},h=(a,i,o)=>i>1?`${(a/i).toLocaleString("en-US",{minimumFractionDigits:0,maximumFractionDigits:4,useGrouping:!1})}${o}`:a.toLocaleString("en-US",{minimumFractionDigits:0,maximumFractionDigits:4,useGrouping:!1});return{formatter:a=>{if(a===0)return"0";const{scale:i,suffix:o,decimals:c}=l(),F=Math.abs(a)*1e-10||1e-10;return m.some(f=>Math.abs(f-a)<F)?h(a,i,o):i>1?`${(a/i).toLocaleString("en-US",{minimumFractionDigits:0,maximumFractionDigits:c,useGrouping:!1})}${o}`:a.toLocaleString("en-US",{minimumFractionDigits:0,maximumFractionDigits:c,useGrouping:!1})},updateVisibleRange:a=>{a.length>0&&(r=Math.min(...a),n=Math.max(...a))},updateLastValues:a=>{m=[...a]}}}const G=t=>g.DateTime.fromSeconds(Number(t)).toFormat("dd/LL/yyyy HH:mm"),P=t=>g.DateTime.fromSeconds(Number(t)).toFormat("HH:mm"),U=()=>{let t=null;return e=>{const r=g.DateTime.fromSeconds(Number(e)),n=r.toFormat("yyyy-MM-dd");return n!==t?(t=n,r.toFormat("dd MMM")):r.toFormat("HH:mm")}},C=(t,e)=>x(Number(t),e),$={time:G,"%":C},Y=(t,e)=>{if(t==="time"&&e&&e.length>0){const r=g.DateTime.fromSeconds(Number(e[0].time)),n=g.DateTime.fromSeconds(Number(e[e.length-1].time));return r.hasSame(n,"day")?P:U()}return $[t]||$.time};exports.createAdaptiveYAxisFormatter=X;exports.formatExactValue=O;exports.getXFormatter=Y;exports.getYFormatter=R;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),d=require("../../utils/cn.cjs"),o=require("./formatters.cjs");function i({point:e,xMeasureUnit:a,yMeasureUnit:t,className:l,decimals:r}){const n=o.getXFormatter(a)(e.time,a),m=t!=="%"&&t!=="$"&&t!=="none"?t:void 0,c=t==="$"?`$${o.formatExactValue(e.value,void 0,r)}`:t==="%"?`${o.formatExactValue(e.value,void 0,r)}%`:o.formatExactValue(e.value,m,r);return s.jsxs("div",{className:d.cn("absolute top-2 left-2 right-2 z-[100] pointer-events-none",l),children:[s.jsx("div",{className:"text-xl sm:text-2xl font-semibold text-foreground whitespace-nowrap overflow-hidden text-ellipsis",children:c}),s.jsx("div",{className:"text-xs sm:text-sm font-medium text-muted-foreground whitespace-nowrap overflow-hidden text-ellipsis mt-0.5",children:n})]})}exports.GraphCurrentValue=i;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),h=require("react"),C=require("../../utils/cn.cjs"),d=require("./formatters.cjs"),v=require("./graph.cjs");function F({points:m,series:j,xMeasureUnit:g,yMeasureUnit:R,className:E,position:t,containerRef:b,decimals:f}){const y=h.useRef(null),[p,l]=h.useState(t),S=d.getXFormatter(g);h.useEffect(()=>{if(!t){l(t);return}const r=b?.current;if(!r){l(t);return}const i=y.current;if(!i){l(t);return}const s=r.getBoundingClientRect(),u=i.getBoundingClientRect();let o=t.x,e=t.y;const a=u.width,x=u.height,c=8;o-a/2<c?o=a/2+c:o+a/2>s.width-c&&(o=s.width-a/2-c);const w=x+8;e-w<c?e=t.y+20:e=t.y-w,l({x:o,y:e})},[t,b]);const _=p?{left:`${p.x}px`,top:`${p.y}px`,transform:"translate(-50%, 0)"}:{};if(m.size===0)return null;const N=Array.from(m.values())[0],$=S(N.time,g);return n.jsx("div",{ref:y,className:C.cn("absolute z-[100] pointer-events-none whitespace-nowrap",E),style:_,children:n.jsxs("div",{className:"bg-background/90 backdrop-blur-sm rounded border border-border p-1.5 sm:p-2 space-y-1 sm:space-y-1.5",children:[n.jsx("div",{className:"text-xs sm:text-sm font-medium text-muted-foreground mb-0.5 sm:mb-1 whitespace-nowrap",children:$}),j.map((r,i)=>{const s=m.get(r.label);if(!s)return null;const u=v.DEFAULT_SERIES_COLORS[i%v.DEFAULT_SERIES_COLORS.length],o=r.color||u.line,e=r.yMeasureUnit||R,a=e!=="%"&&e!=="$"&&e!=="none"?e:void 0,x=e==="$"?`$${d.formatExactValue(s.value,void 0,f)}`:e==="%"?`${d.formatExactValue(s.value,void 0,f)}%`:d.formatExactValue(s.value,a,f);return n.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2 text-xs sm:text-sm whitespace-nowrap",children:[n.jsx("div",{className:"w-1.5 h-1.5 sm:w-2 sm:h-2 rounded-full flex-shrink-0",style:{backgroundColor:o}}),n.jsxs("span",{className:"text-muted-foreground whitespace-nowrap",children:[r.label,":"]}),n.jsx("span",{className:"font-medium text-foreground whitespace-nowrap",children:x})]},r.label)})]})})}exports.GraphTooltip=F;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("react/jsx-runtime"),be=require("lightweight-charts"),i=require("react"),ve=require("../../hooks/use-media-query.cjs"),ce=require("../../utils/cn.cjs"),G=require("../../utils/colors.cjs"),Y=require("./default-config.cjs"),oe=require("./formatters.cjs"),Ce=require("./graph-current-value.cjs"),Se=require("./graph-tooltip.cjs"),xe=require("./plugins/vertical-line.cjs");function Re(e){const V=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const p in e)if(p!=="default"){const A=Object.getOwnPropertyDescriptor(e,p);Object.defineProperty(V,p,A.get?A:{enumerable:!0,get:()=>e[p]})}}return V.default=e,Object.freeze(V)}const re=Re(i),H=[{line:"#02c39a",top:"rgba(2, 195, 154, 0.56)",bottom:"rgba(2, 195, 154, 0.04)"},{line:"#3b82f6",top:"rgba(59, 130, 246, 0.56)",bottom:"rgba(59, 130, 246, 0.04)"},{line:"#f59e0b",top:"rgba(245, 158, 11, 0.56)",bottom:"rgba(245, 158, 11, 0.04)"},{line:"#ef4444",top:"rgba(239, 68, 68, 0.56)",bottom:"rgba(239, 68, 68, 0.04)"},{line:"#8b5cf6",top:"rgba(139, 92, 246, 0.56)",bottom:"rgba(139, 92, 246, 0.04)"},{line:"#ec4899",top:"rgba(236, 72, 153, 0.56)",bottom:"rgba(236, 72, 153, 0.04)"},{line:"#10b981",top:"rgba(16, 185, 129, 0.56)",bottom:"rgba(16, 185, 129, 0.04)"},{line:"#06b6d4",top:"rgba(6, 182, 212, 0.56)",bottom:"rgba(6, 182, 212, 0.04)"}];function ye({series:e,className:V,showLegend:p=!1,onUnselectSeries:A,xMeasureUnit:L="time",yMeasureUnit:q="token",optionsOverrides:D,verticalLineOptions:I}){const R=i.useRef(null),S=i.useRef(new Map),$=i.useRef(!1),X=i.useRef(new Set),ne=i.useRef(0),ae=i.useRef(!0),W=i.useRef(null),ue=i.useRef(null),F=i.useRef(null),Z=i.useRef(null),N=ve.useIsMobile(),P=re.useMemo(()=>e.flatMap(o=>o.data),[e]),fe=re.useMemo(()=>{if(e.length>0){const o=e[e.length-1];if(o.data.length>0)return o.data[o.data.length-1]}},[e]),[le,Q]=i.useState(()=>{if(!fe)return;const o=new Map;for(const r of e)r.data.length>0&&o.set(r.label,r.data[r.data.length-1]);return o}),[se,M]=i.useState(null);i.useEffect(()=>{const o=()=>{if(R.current&&F.current){const d=F.current.clientWidth,a=F.current.clientHeight;R.current.resize(d,a),R.current.timeScale().fitContent()}},r=F.current,l=r?new ResizeObserver(o):null;return r&&l?.observe(r),()=>{r&&l?.unobserve(r)}},[]),i.useEffect(()=>{if(!Z.current||$.current)return;const o=Y.getDefaultOptions(),r=G.resolveCSSColor("hsl(var(--foreground))","rgb(0, 0, 0)"),l=be.createChart(Z.current,{...o,rightPriceScale:{...o.rightPriceScale||{},visible:!N,textColor:r},...D});return R.current=l,$.current=!0,()=>{l.remove(),R.current=null,$.current=!1,S.current.clear()}},[N,D]),i.useEffect(()=>{const o=R.current;if(!o||e.length===0)return;const r=L==="time"?oe.getXFormatter(L,P):oe.getXFormatter(L),l=P.map(t=>t.value),{formatter:d,updateVisibleRange:a,updateLastValues:f}=oe.createAdaptiveYAxisFormatter(l);W.current=a,ue.current=f;const b=e.filter(t=>t.data.length>0).map(t=>t.data[t.data.length-1].value);f(b);const x=Y.getDefaultOptions();o.applyOptions({localization:{...x.localization||{},timeFormatter:r?(t=>r(parseFloat(t),void 0)):void 0},timeScale:{...x.timeScale||{},tickMarkFormatter:r?(t=>r(parseFloat(t),void 0)):void 0,minBarSpacing:0}});const j=(P.length>0?Math.min(...P.map(t=>t.value)):0)<0,y=P.some(t=>t.value===0),g=!j&&y,s=e.length>1,u=s||N,c=G.resolveCSSColor("hsl(var(--foreground))","rgb(0, 0, 0)");o.applyOptions({rightPriceScale:{...x.rightPriceScale||{},visible:!u,textColor:c,...g&&{scaleMargins:{top:.3,bottom:0}}}});const h=new Set(S.current.keys()),w=new Set(e.map(t=>t.label));for(const t of h)if(!w.has(t)){const n=S.current.get(t);n&&(o.removeSeries(n),S.current.delete(t))}const O=Y.getDefaultSeries(),z=[];let k=0;for(let t=0;t<e.length;t++){const n=e[t],ee=H[t%H.length],B=n.color||ee.line;let T,_;if(n.color)if(n.topColor&&n.bottomColor)T=n.topColor,_=n.bottomColor;else if(n.topColor){const C=G.generateColorsFromBase(B);T=n.topColor,_=C.bottomColor}else if(n.bottomColor)T=G.generateColorsFromBase(B).topColor,_=n.bottomColor;else{const C=G.generateColorsFromBase(B);T=C.topColor,_=C.bottomColor}else T=n.topColor||ee.top,_=n.bottomColor||ee.bottom;if(n.data.length===0){const C=S.current.get(n.label);C&&(o.removeSeries(C),S.current.delete(n.label));continue}const he=(n.data.length>0?Math.min(...n.data.map(C=>C.value)):0)<0,me=n.data.some(C=>C.value===0),pe=!he&&me,te=s?k===0?"right":`scale-${k}`:"right";s&&z.push({priceScaleId:te||"right",shouldPreventNegativeAxis:pe,seriesIndex:k});let E=S.current.get(n.label);E?(E.applyOptions({lineColor:B,topColor:T,bottomColor:_,priceScaleId:te,priceFormat:{type:"custom",formatter:d}}),E.setData(n.data)):(E=o.addAreaSeries({...O,lineColor:B,topColor:T,bottomColor:_,priceScaleId:te,priceFormat:{type:"custom",formatter:d}}),E.setData(n.data),S.current.set(n.label,E)),k++}if(s&&z.length>0)for(const t of z)try{const n=o.priceScale(t.priceScaleId);n&&n.applyOptions({visible:!1,autoScale:!0,scaleMargins:{top:.1,bottom:.1,...t.shouldPreventNegativeAxis&&{top:.3,bottom:0}},alignLabels:!0,borderVisible:!0,borderColor:"rgba(224, 227, 235, 0.1)",entireTextOnly:!1,textColor:c})}catch(n){console.warn(`Failed to configure price scale ${t.priceScaleId} for series ${t.seriesIndex}:`,n)}else if(!s)try{const t=o.priceScale("right");t&&t.applyOptions({visible:!N,autoScale:!0,scaleMargins:{top:.1,bottom:.1,...g&&{top:.3,bottom:0}},alignLabels:!0,borderVisible:!0,borderColor:"rgba(224, 227, 235, 0.1)",entireTextOnly:!1,textColor:c})}catch{}const K=new Set(e.map(t=>t.label)),ge=K.size!==X.current.size||[...K].some(t=>!X.current.has(t)),de=P.length!==ne.current;(ae.current||ge||de||N)&&(o.timeScale().fitContent(),ae.current=!1),X.current=K,ne.current=P.length;const U=new Map;for(const t of e)t.data.length>0&&U.set(t.label,t.data[t.data.length-1]);Q(U.size>0?U:void 0)},[e,P,L,q,N]),i.useEffect(()=>{const o=R.current;if(!o||e.length===0)return;const r=e.length===1;let l;for(const a of e)if(a.data.length>0){l=a.data[a.data.length-1].time;break}if(!l)return;const d=a=>{const{time:f=l,seriesData:b,point:x}=a||{},v=Array.from(S.current.values());if(!x||!f){const g=new Map;for(const s of e)s.data.length>0&&g.set(s.label,s.data[s.data.length-1]);if(Q(g.size>0?g:void 0),r)M(null);else if(v[0]&&l){const u=o.timeScale().timeToCoordinate(l),c=e[0];if(c.data.length>0){const h=c.data[c.data.length-1].value,w=v[0].priceToCoordinate(h);u!==null&&w!==null&&M({x:u,y:w})}}return}const j=new Map;let y;for(let g=0;g<e.length;g++){const s=e[g],u=v[g];if(!u)continue;const c=b?.get(u),h=c&&"value"in c?c.value:void 0,w=s.data[s.data.length-1],O=h!==void 0?h:w?.value??0;g===0&&(y=O),j.set(s.label,{value:O,time:f})}if(Q(j),y!==void 0&&v[0]){const s=o.timeScale().timeToCoordinate(f),u=v[0].priceToCoordinate(y);if(s!==null&&u!==null){const c=F.current;if(c){const h=c.querySelector(".LightweightChart");if(h){const w=h.getBoundingClientRect(),O=c.getBoundingClientRect(),z=s+(w.left-O.left),k=u+(w.top-O.top);M({x:z,y:k})}else M({x:s,y:u})}else M({x:s,y:u})}else M(null)}else M(null)};return o.subscribeCrosshairMove(d),r||requestAnimationFrame(()=>{const a=Array.from(S.current.values());if(a[0]&&l&&e[0]?.data.length>0){const b=o.timeScale().timeToCoordinate(l),x=e[0].data[e[0].data.length-1].value,v=a[0].priceToCoordinate(x);b!==null&&v!==null&&M({x:b,y:v})}}),()=>{o.unsubscribeCrosshairMove(d)}},[e]),i.useEffect(()=>{const o=R.current;if(!o||e.length===0)return;const r=o.timeScale(),l=Math.max(...e.map(a=>a.data.length)),d=()=>{if(l===0)return;const a=r.getVisibleLogicalRange();if(!a)return;const f={from:0,to:l-1},b=typeof a.from=="number"?a.from:0,x=typeof a.to=="number"?a.to:l-1;if(W.current){const g=Math.max(0,Math.floor(b)),s=Math.min(l-1,Math.ceil(x)),u=[];for(const c of e)for(let h=g;h<=s&&h<c.data.length;h++)u.push(c.data[h].value);u.length>0&&W.current(u)}const v=.01;let j=!1;const y={...a};b<f.from-v&&(y.from=f.from,j=!0),x>f.to+v&&(y.to=f.to,j=!0),j&&r.setVisibleLogicalRange(y)};return r.subscribeVisibleLogicalRangeChange(d),()=>{r.unsubscribeVisibleLogicalRangeChange(d)}},[e]),i.useEffect(()=>{const o=R.current,r=Array.from(S.current.values()),l=[];if(o&&r.length>0&&I){const d=Y.getDefaultVerticalLine(),a=r[0];for(const f of I){const b=new xe.VertLine(o,a,f.xCoordinate,{...d,...f.options||{}});a.attachPrimitive(b),l.push(b)}}return()=>{if(r.length>0){const d=r[0];for(const a of l)d.detachPrimitive(a)}}},[I]);const J=e.length===1,ie=re.useMemo(()=>{if(J&&e.length>0){const o=e[0];if(o.data.length>0)return o.data[o.data.length-1]}},[J,e]);return m.jsxs("div",{ref:F,className:ce.cn("relative z-[1] w-full h-full overflow-hidden p-0",V),children:[J&&ie&&m.jsx(Ce.GraphCurrentValue,{point:ie,xMeasureUnit:L,yMeasureUnit:q}),le&&se&&m.jsx(Se.GraphTooltip,{points:le,xMeasureUnit:L,yMeasureUnit:q,series:e,position:se,containerRef:F}),p&&m.jsx(we,{series:e,onUnselect:A}),m.jsx("div",{ref:Z,className:"LightweightChart w-full h-full overflow-hidden"})]})}function we({series:e,onUnselect:V}){return m.jsx("div",{className:"absolute top-0 left-2 z-[10] flex flex-wrap gap-2",children:e.map((p,A)=>{const L=H[A%H.length],q=p.color||L.line,D=p.data.length===0;return m.jsxs("div",{className:ce.cn("flex items-center gap-1.5 px-2 py-1 bg-background/80 backdrop-blur-sm rounded border border-border",D&&"opacity-50"),children:[m.jsx("div",{className:"w-3 h-3 rounded-sm",style:{backgroundColor:q}}),m.jsxs("span",{className:"text-[10px] sm:text-xs font-medium text-foreground",children:[p.label,D&&" (no data)"]}),V&&m.jsx("button",{type:"button",onClick:I=>{I.stopPropagation(),V(p.label)},className:"ml-1 flex items-center justify-center w-4 h-4 rounded-sm hover:bg-muted transition-colors cursor-pointer","aria-label":`Remove ${p.label}`,children:m.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-muted-foreground hover:text-foreground","aria-hidden":"true",children:[m.jsx("title",{children:"Close"}),m.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),m.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},p.label)})})}exports.DEFAULT_SERIES_COLORS=H;exports.Graph=ye;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("react/jsx-runtime"),ve=require("lightweight-charts"),i=require("react"),Ce=require("../../hooks/use-media-query.cjs"),ue=require("../../utils/cn.cjs"),G=require("../../utils/colors.cjs"),Y=require("./default-config.cjs"),oe=require("./formatters.cjs"),Se=require("./graph-current-value.cjs"),xe=require("./graph-tooltip.cjs"),Re=require("./plugins/vertical-line.cjs");function ye(e){const V=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const p in e)if(p!=="default"){const A=Object.getOwnPropertyDescriptor(e,p);Object.defineProperty(V,p,A.get?A:{enumerable:!0,get:()=>e[p]})}}return V.default=e,Object.freeze(V)}const re=ye(i),H=[{line:"#02c39a",top:"rgba(2, 195, 154, 0.56)",bottom:"rgba(2, 195, 154, 0.04)"},{line:"#3b82f6",top:"rgba(59, 130, 246, 0.56)",bottom:"rgba(59, 130, 246, 0.04)"},{line:"#f59e0b",top:"rgba(245, 158, 11, 0.56)",bottom:"rgba(245, 158, 11, 0.04)"},{line:"#ef4444",top:"rgba(239, 68, 68, 0.56)",bottom:"rgba(239, 68, 68, 0.04)"},{line:"#8b5cf6",top:"rgba(139, 92, 246, 0.56)",bottom:"rgba(139, 92, 246, 0.04)"},{line:"#ec4899",top:"rgba(236, 72, 153, 0.56)",bottom:"rgba(236, 72, 153, 0.04)"},{line:"#10b981",top:"rgba(16, 185, 129, 0.56)",bottom:"rgba(16, 185, 129, 0.04)"},{line:"#06b6d4",top:"rgba(6, 182, 212, 0.56)",bottom:"rgba(6, 182, 212, 0.04)"}];function we({series:e,className:V,showLegend:p=!1,onUnselectSeries:A,xMeasureUnit:L="time",yMeasureUnit:q="token",optionsOverrides:I,verticalLineOptions:z,currentValueDecimals:ne}){const R=i.useRef(null),S=i.useRef(new Map),$=i.useRef(!1),X=i.useRef(new Set),ae=i.useRef(0),le=i.useRef(!0),W=i.useRef(null),fe=i.useRef(null),F=i.useRef(null),Z=i.useRef(null),N=Ce.useIsMobile(),P=re.useMemo(()=>e.flatMap(o=>o.data),[e]),de=re.useMemo(()=>{if(e.length>0){const o=e[e.length-1];if(o.data.length>0)return o.data[o.data.length-1]}},[e]),[se,Q]=i.useState(()=>{if(!de)return;const o=new Map;for(const r of e)r.data.length>0&&o.set(r.label,r.data[r.data.length-1]);return o}),[ie,M]=i.useState(null);i.useEffect(()=>{const o=()=>{if(R.current&&F.current){const g=F.current.clientWidth,a=F.current.clientHeight;R.current.resize(g,a),R.current.timeScale().fitContent()}},r=F.current,l=r?new ResizeObserver(o):null;return r&&l?.observe(r),()=>{r&&l?.unobserve(r)}},[]),i.useEffect(()=>{if(!Z.current||$.current)return;const o=Y.getDefaultOptions(),r=G.resolveCSSColor("hsl(var(--foreground))","rgb(0, 0, 0)"),l=ve.createChart(Z.current,{...o,rightPriceScale:{...o.rightPriceScale||{},visible:!N,textColor:r},...I});return R.current=l,$.current=!0,()=>{l.remove(),R.current=null,$.current=!1,S.current.clear()}},[N,I]),i.useEffect(()=>{const o=R.current;if(!o||e.length===0)return;const r=L==="time"?oe.getXFormatter(L,P):oe.getXFormatter(L),l=P.map(t=>t.value),{formatter:g,updateVisibleRange:a,updateLastValues:f}=oe.createAdaptiveYAxisFormatter(l);W.current=a,fe.current=f;const b=e.filter(t=>t.data.length>0).map(t=>t.data[t.data.length-1].value);f(b);const x=Y.getDefaultOptions();o.applyOptions({localization:{...x.localization||{},timeFormatter:r?(t=>r(parseFloat(t),void 0)):void 0},timeScale:{...x.timeScale||{},tickMarkFormatter:r?(t=>r(parseFloat(t),void 0)):void 0,minBarSpacing:0}});const j=(P.length>0?Math.min(...P.map(t=>t.value)):0)<0,y=P.some(t=>t.value===0),d=!j&&y,s=e.length>1,u=s||N,c=G.resolveCSSColor("hsl(var(--foreground))","rgb(0, 0, 0)");o.applyOptions({rightPriceScale:{...x.rightPriceScale||{},visible:!u,textColor:c,...d&&{scaleMargins:{top:.3,bottom:0}}}});const h=new Set(S.current.keys()),w=new Set(e.map(t=>t.label));for(const t of h)if(!w.has(t)){const n=S.current.get(t);n&&(o.removeSeries(n),S.current.delete(t))}const O=Y.getDefaultSeries(),D=[];let k=0;for(let t=0;t<e.length;t++){const n=e[t],ee=H[t%H.length],B=n.color||ee.line;let T,_;if(n.color)if(n.topColor&&n.bottomColor)T=n.topColor,_=n.bottomColor;else if(n.topColor){const C=G.generateColorsFromBase(B);T=n.topColor,_=C.bottomColor}else if(n.bottomColor)T=G.generateColorsFromBase(B).topColor,_=n.bottomColor;else{const C=G.generateColorsFromBase(B);T=C.topColor,_=C.bottomColor}else T=n.topColor||ee.top,_=n.bottomColor||ee.bottom;if(n.data.length===0){const C=S.current.get(n.label);C&&(o.removeSeries(C),S.current.delete(n.label));continue}const me=(n.data.length>0?Math.min(...n.data.map(C=>C.value)):0)<0,pe=n.data.some(C=>C.value===0),be=!me&&pe,te=s?k===0?"right":`scale-${k}`:"right";s&&D.push({priceScaleId:te||"right",shouldPreventNegativeAxis:be,seriesIndex:k});let E=S.current.get(n.label);E?(E.applyOptions({lineColor:B,topColor:T,bottomColor:_,priceScaleId:te,priceFormat:{type:"custom",formatter:g}}),E.setData(n.data)):(E=o.addAreaSeries({...O,lineColor:B,topColor:T,bottomColor:_,priceScaleId:te,priceFormat:{type:"custom",formatter:g}}),E.setData(n.data),S.current.set(n.label,E)),k++}if(s&&D.length>0)for(const t of D)try{const n=o.priceScale(t.priceScaleId);n&&n.applyOptions({visible:!1,autoScale:!0,scaleMargins:{top:.1,bottom:.1,...t.shouldPreventNegativeAxis&&{top:.3,bottom:0}},alignLabels:!0,borderVisible:!0,borderColor:"rgba(224, 227, 235, 0.1)",entireTextOnly:!1,textColor:c})}catch(n){console.warn(`Failed to configure price scale ${t.priceScaleId} for series ${t.seriesIndex}:`,n)}else if(!s)try{const t=o.priceScale("right");t&&t.applyOptions({visible:!N,autoScale:!0,scaleMargins:{top:.1,bottom:.1,...d&&{top:.3,bottom:0}},alignLabels:!0,borderVisible:!0,borderColor:"rgba(224, 227, 235, 0.1)",entireTextOnly:!1,textColor:c})}catch{}const K=new Set(e.map(t=>t.label)),ge=K.size!==X.current.size||[...K].some(t=>!X.current.has(t)),he=P.length!==ae.current;(le.current||ge||he||N)&&(o.timeScale().fitContent(),le.current=!1),X.current=K,ae.current=P.length;const U=new Map;for(const t of e)t.data.length>0&&U.set(t.label,t.data[t.data.length-1]);Q(U.size>0?U:void 0)},[e,P,L,q,N]),i.useEffect(()=>{const o=R.current;if(!o||e.length===0)return;const r=e.length===1;let l;for(const a of e)if(a.data.length>0){l=a.data[a.data.length-1].time;break}if(!l)return;const g=a=>{const{time:f=l,seriesData:b,point:x}=a||{},v=Array.from(S.current.values());if(!x||!f){const d=new Map;for(const s of e)s.data.length>0&&d.set(s.label,s.data[s.data.length-1]);if(Q(d.size>0?d:void 0),r)M(null);else if(v[0]&&l){const u=o.timeScale().timeToCoordinate(l),c=e[0];if(c.data.length>0){const h=c.data[c.data.length-1].value,w=v[0].priceToCoordinate(h);u!==null&&w!==null&&M({x:u,y:w})}}return}const j=new Map;let y;for(let d=0;d<e.length;d++){const s=e[d],u=v[d];if(!u)continue;const c=b?.get(u),h=c&&"value"in c?c.value:void 0,w=s.data[s.data.length-1],O=h!==void 0?h:w?.value??0;d===0&&(y=O),j.set(s.label,{value:O,time:f})}if(Q(j),y!==void 0&&v[0]){const s=o.timeScale().timeToCoordinate(f),u=v[0].priceToCoordinate(y);if(s!==null&&u!==null){const c=F.current;if(c){const h=c.querySelector(".LightweightChart");if(h){const w=h.getBoundingClientRect(),O=c.getBoundingClientRect(),D=s+(w.left-O.left),k=u+(w.top-O.top);M({x:D,y:k})}else M({x:s,y:u})}else M({x:s,y:u})}else M(null)}else M(null)};return o.subscribeCrosshairMove(g),r||requestAnimationFrame(()=>{const a=Array.from(S.current.values());if(a[0]&&l&&e[0]?.data.length>0){const b=o.timeScale().timeToCoordinate(l),x=e[0].data[e[0].data.length-1].value,v=a[0].priceToCoordinate(x);b!==null&&v!==null&&M({x:b,y:v})}}),()=>{o.unsubscribeCrosshairMove(g)}},[e]),i.useEffect(()=>{const o=R.current;if(!o||e.length===0)return;const r=o.timeScale(),l=Math.max(...e.map(a=>a.data.length)),g=()=>{if(l===0)return;const a=r.getVisibleLogicalRange();if(!a)return;const f={from:0,to:l-1},b=typeof a.from=="number"?a.from:0,x=typeof a.to=="number"?a.to:l-1;if(W.current){const d=Math.max(0,Math.floor(b)),s=Math.min(l-1,Math.ceil(x)),u=[];for(const c of e)for(let h=d;h<=s&&h<c.data.length;h++)u.push(c.data[h].value);u.length>0&&W.current(u)}const v=.01;let j=!1;const y={...a};b<f.from-v&&(y.from=f.from,j=!0),x>f.to+v&&(y.to=f.to,j=!0),j&&r.setVisibleLogicalRange(y)};return r.subscribeVisibleLogicalRangeChange(g),()=>{r.unsubscribeVisibleLogicalRangeChange(g)}},[e]),i.useEffect(()=>{const o=R.current,r=Array.from(S.current.values()),l=[];if(o&&r.length>0&&z){const g=Y.getDefaultVerticalLine(),a=r[0];for(const f of z){const b=new Re.VertLine(o,a,f.xCoordinate,{...g,...f.options||{}});a.attachPrimitive(b),l.push(b)}}return()=>{if(r.length>0){const g=r[0];for(const a of l)g.detachPrimitive(a)}}},[z]);const J=e.length===1,ce=re.useMemo(()=>{if(J&&e.length>0){const o=e[0];if(o.data.length>0)return o.data[o.data.length-1]}},[J,e]);return m.jsxs("div",{ref:F,className:ue.cn("relative z-[1] w-full h-full overflow-hidden p-0",V),children:[J&&ce&&m.jsx(Se.GraphCurrentValue,{point:ce,xMeasureUnit:L,yMeasureUnit:q,decimals:ne}),se&&ie&&m.jsx(xe.GraphTooltip,{points:se,xMeasureUnit:L,yMeasureUnit:q,series:e,position:ie,containerRef:F,decimals:ne}),p&&m.jsx(Ve,{series:e,onUnselect:A}),m.jsx("div",{ref:Z,className:"LightweightChart w-full h-full overflow-hidden"})]})}function Ve({series:e,onUnselect:V}){return m.jsx("div",{className:"absolute top-0 left-2 z-[10] flex flex-wrap gap-2",children:e.map((p,A)=>{const L=H[A%H.length],q=p.color||L.line,I=p.data.length===0;return m.jsxs("div",{className:ue.cn("flex items-center gap-1.5 px-2 py-1 bg-background/80 backdrop-blur-sm rounded border border-border",I&&"opacity-50"),children:[m.jsx("div",{className:"w-3 h-3 rounded-sm",style:{backgroundColor:q}}),m.jsxs("span",{className:"text-[10px] sm:text-xs font-medium text-foreground",children:[p.label,I&&" (no data)"]}),V&&m.jsx("button",{type:"button",onClick:z=>{z.stopPropagation(),V(p.label)},className:"ml-1 flex items-center justify-center w-4 h-4 rounded-sm hover:bg-muted transition-colors cursor-pointer","aria-label":`Remove ${p.label}`,children:m.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-muted-foreground hover:text-foreground","aria-hidden":"true",children:[m.jsx("title",{children:"Close"}),m.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),m.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},p.label)})})}exports.DEFAULT_SERIES_COLORS=H;exports.Graph=we;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),i=require("react"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),i=require("react"),B=require("sonner"),W=require("../../hooks/use-media-query.cjs"),z=require("../buttons/range-buttons/range-buttons.cjs"),l=require("../graph/graph.cjs"),H=require("../graph/graph-view.cjs"),P=require("./graph-dropdown.cjs"),$=({size:t=16})=>e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-label":"Expand fullscreen",children:[e.jsx("title",{children:"Expand fullscreen"}),e.jsx("path",{d:"M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3"})]}),Q=({size:t=16})=>e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-label":"Exit fullscreen",children:[e.jsx("title",{children:"Exit fullscreen"}),e.jsx("path",{d:"M8 3v3a2 2 0 0 1-2 2H3m18 0h-3a2 2 0 0 1-2-2V3m0 18v-3a2 2 0 0 1 2-2h3M3 16h3a2 2 0 0 1 2 2v3"})]});function J({data:t,yMeasureUnit:n,height:h=306,defaultGraph:g,onGraphSelected:v,graphs:b,isMultipleSelect:y,range:A,rangeList:E,setRange:L,onGraphExpanded:w,isGraphExpanded:R,onUnselectSeries:C,graphsWithNoData:D,loadingGraphs:I,noDataMessage:j="No data available for this graph",currentValueDecimals:k}){const a=i.useMemo(()=>Array.isArray(t)?t:t?[t]:[],[t]),S=i.useMemo(()=>Array.isArray(t)&&t.length>1,[t]),O=W.useIsMobile(),N=i.useCallback((c,f)=>{B.toast.error(j)},[j]),M=i.useMemo(()=>{if(n)return Array.isArray(n)?n[0]:n},[n]),T=e.jsxs("div",{className:"z-10 w-full flex flex-row flex-wrap sm:flex-nowrap items-center gap-2",children:[e.jsx("div",{children:v&&b&&g&&e.jsx(P.GraphDropdown,{onSelected:v,items:b,defaultItem:g,multiple:y,graphsWithNoData:D,loadingGraphs:I,onNoDataSelected:N})}),e.jsxs("div",{className:"flex flex-row flex-nowrap justify-start sm:justify-end items-center flex-1",children:[e.jsx(z.RangeButtons,{range:A,rangeList:E,setRange:L}),!O&&w&&e.jsx("button",{type:"button",className:"px-2.5 py-1.5 flex min-w-[44px] min-h-[26px] justify-center items-center text-xs leading-[14px] font-medium text-center rounded-md border cursor-pointer transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring bg-muted border-muted text-muted-foreground hover:border-secondary ml-1.5",onClick:w,children:R?e.jsx(Q,{size:16}):e.jsx($,{size:16})})]})]}),u=i.useRef(new Map),x=i.useRef(0),q=i.useMemo(()=>{const c=Array.isArray(n)?n:void 0;return a.map((f,_)=>{const d=f?.title||`Series ${_+1}`;if(!u.current.has(d)){const r=new Set(Array.from(u.current.values()));let o=x.current;for(let s=0;s<l.DEFAULT_SERIES_COLORS.length;s++){const m=(x.current+s)%l.DEFAULT_SERIES_COLORS.length;if(!r.has(m)){o=m;break}}u.current.set(d,o),x.current=(o+1)%l.DEFAULT_SERIES_COLORS.length}const F=u.current.get(d)??0,p=l.DEFAULT_SERIES_COLORS[F%l.DEFAULT_SERIES_COLORS.length];return{data:[...f?.data||[]].sort((r,o)=>{const s=typeof r.time=="number"?r.time:Number(r.time),m=typeof o.time=="number"?o.time:Number(o.time);return s-m}).reduce((r,o)=>{const s=o.time;return r.length===0||r[r.length-1].time!==s?r.push({time:s,value:o.value}):r[r.length-1]={time:s,value:o.value},r},[]),label:d,yMeasureUnit:c?.[_]??(Array.isArray(n)?void 0:n),color:p.line,topColor:p.top,bottomColor:p.bottom}})},[a,n]),V=S&&a.length>0?a.some(c=>!c):!t;return e.jsx("div",{style:{width:"100%",height:h?`${h}px`:void 0},className:"w-full",children:e.jsx(H.GraphViewWithData,{series:q,loading:V,toolbar:T,size:h?"full":"default",containerClassName:"h-full",showLegend:S,onUnselectSeries:C,yMeasureUnit:M,currentValueDecimals:k})})}exports.TradingView=J;
|
|
@@ -51,7 +51,7 @@ const { MIN_DISPLAY_THRESHOLD: c, MAX_EXPONENTIAL_THRESHOLD: L } = I, H = (t, e,
|
|
|
51
51
|
token: G,
|
|
52
52
|
none: O
|
|
53
53
|
}, k = (t) => D[t] || D.token;
|
|
54
|
-
function w(t, e, r =
|
|
54
|
+
function w(t, e, r = 4) {
|
|
55
55
|
if (t === 0)
|
|
56
56
|
return e ? `0 ${e}` : "0";
|
|
57
57
|
const n = t.toLocaleString("en-US", {
|
|
@@ -1,27 +1,28 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { cn as
|
|
3
|
-
import { getXFormatter as c, formatExactValue as
|
|
4
|
-
function
|
|
1
|
+
import { jsxs as a, jsx as l } from "react/jsx-runtime";
|
|
2
|
+
import { cn as i } from "../../utils/cn.js";
|
|
3
|
+
import { getXFormatter as c, formatExactValue as r } from "./formatters.js";
|
|
4
|
+
function u({
|
|
5
5
|
point: e,
|
|
6
|
-
xMeasureUnit:
|
|
6
|
+
xMeasureUnit: m,
|
|
7
7
|
yMeasureUnit: t,
|
|
8
|
-
className:
|
|
8
|
+
className: s,
|
|
9
|
+
decimals: o
|
|
9
10
|
}) {
|
|
10
|
-
const
|
|
11
|
-
return /* @__PURE__ */
|
|
11
|
+
const d = c(m)(e.time, m), n = t !== "%" && t !== "$" && t !== "none" ? t : void 0, x = t === "$" ? `$${r(e.value, void 0, o)}` : t === "%" ? `${r(e.value, void 0, o)}%` : r(e.value, n, o);
|
|
12
|
+
return /* @__PURE__ */ a(
|
|
12
13
|
"div",
|
|
13
14
|
{
|
|
14
|
-
className:
|
|
15
|
+
className: i(
|
|
15
16
|
"absolute top-2 left-2 right-2 z-[100] pointer-events-none",
|
|
16
|
-
|
|
17
|
+
s
|
|
17
18
|
),
|
|
18
19
|
children: [
|
|
19
|
-
/* @__PURE__ */
|
|
20
|
-
/* @__PURE__ */
|
|
20
|
+
/* @__PURE__ */ l("div", { className: "text-xl sm:text-2xl font-semibold text-foreground whitespace-nowrap overflow-hidden text-ellipsis", children: x }),
|
|
21
|
+
/* @__PURE__ */ l("div", { className: "text-xs sm:text-sm font-medium text-muted-foreground whitespace-nowrap overflow-hidden text-ellipsis mt-0.5", children: d })
|
|
21
22
|
]
|
|
22
23
|
}
|
|
23
24
|
);
|
|
24
25
|
}
|
|
25
26
|
export {
|
|
26
|
-
|
|
27
|
+
u as GraphCurrentValue
|
|
27
28
|
};
|
|
@@ -1,65 +1,66 @@
|
|
|
1
|
-
import { jsx as m, jsxs as
|
|
2
|
-
import { useRef as
|
|
3
|
-
import { cn as
|
|
4
|
-
import { getXFormatter as
|
|
5
|
-
import { DEFAULT_SERIES_COLORS as
|
|
6
|
-
function
|
|
1
|
+
import { jsx as m, jsxs as h } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as j, useState as k, useEffect as P } from "react";
|
|
3
|
+
import { cn as A } from "../../utils/cn.js";
|
|
4
|
+
import { getXFormatter as z, formatExactValue as x } from "./formatters.js";
|
|
5
|
+
import { DEFAULT_SERIES_COLORS as v } from "./graph.js";
|
|
6
|
+
function U({
|
|
7
7
|
points: d,
|
|
8
|
-
series:
|
|
9
|
-
xMeasureUnit:
|
|
10
|
-
yMeasureUnit:
|
|
11
|
-
className:
|
|
8
|
+
series: N,
|
|
9
|
+
xMeasureUnit: g,
|
|
10
|
+
yMeasureUnit: R,
|
|
11
|
+
className: $,
|
|
12
12
|
position: t,
|
|
13
|
-
containerRef:
|
|
13
|
+
containerRef: b,
|
|
14
|
+
decimals: u
|
|
14
15
|
}) {
|
|
15
|
-
const
|
|
16
|
-
|
|
16
|
+
const w = j(null), [f, l] = k(t), C = z(g);
|
|
17
|
+
P(() => {
|
|
17
18
|
if (!t) {
|
|
18
19
|
l(t);
|
|
19
20
|
return;
|
|
20
21
|
}
|
|
21
|
-
const r =
|
|
22
|
+
const r = b?.current;
|
|
22
23
|
if (!r) {
|
|
23
24
|
l(t);
|
|
24
25
|
return;
|
|
25
26
|
}
|
|
26
|
-
const c =
|
|
27
|
+
const c = w.current;
|
|
27
28
|
if (!c) {
|
|
28
29
|
l(t);
|
|
29
30
|
return;
|
|
30
31
|
}
|
|
31
32
|
const o = r.getBoundingClientRect(), i = c.getBoundingClientRect();
|
|
32
33
|
let n = t.x, e = t.y;
|
|
33
|
-
const s = i.width,
|
|
34
|
+
const s = i.width, p = i.height, a = 8;
|
|
34
35
|
n - s / 2 < a ? n = s / 2 + a : n + s / 2 > o.width - a && (n = o.width - s / 2 - a);
|
|
35
|
-
const
|
|
36
|
-
e -
|
|
37
|
-
}, [t,
|
|
38
|
-
const
|
|
39
|
-
left: `${
|
|
40
|
-
top: `${
|
|
36
|
+
const y = p + 8;
|
|
37
|
+
e - y < a ? e = t.y + 20 : e = t.y - y, l({ x: n, y: e });
|
|
38
|
+
}, [t, b]);
|
|
39
|
+
const E = f ? {
|
|
40
|
+
left: `${f.x}px`,
|
|
41
|
+
top: `${f.y}px`,
|
|
41
42
|
transform: "translate(-50%, 0)"
|
|
42
43
|
// Center horizontally
|
|
43
44
|
} : {};
|
|
44
45
|
if (d.size === 0)
|
|
45
46
|
return null;
|
|
46
|
-
const
|
|
47
|
+
const F = Array.from(d.values())[0], S = C(F.time, g);
|
|
47
48
|
return /* @__PURE__ */ m(
|
|
48
49
|
"div",
|
|
49
50
|
{
|
|
50
|
-
ref:
|
|
51
|
-
className:
|
|
51
|
+
ref: w,
|
|
52
|
+
className: A(
|
|
52
53
|
"absolute z-[100] pointer-events-none whitespace-nowrap",
|
|
53
|
-
|
|
54
|
+
$
|
|
54
55
|
),
|
|
55
|
-
style:
|
|
56
|
-
children: /* @__PURE__ */
|
|
57
|
-
/* @__PURE__ */ m("div", { className: "text-xs sm:text-sm font-medium text-muted-foreground mb-0.5 sm:mb-1 whitespace-nowrap", children:
|
|
58
|
-
|
|
56
|
+
style: E,
|
|
57
|
+
children: /* @__PURE__ */ h("div", { className: "bg-background/90 backdrop-blur-sm rounded border border-border p-1.5 sm:p-2 space-y-1 sm:space-y-1.5", children: [
|
|
58
|
+
/* @__PURE__ */ m("div", { className: "text-xs sm:text-sm font-medium text-muted-foreground mb-0.5 sm:mb-1 whitespace-nowrap", children: S }),
|
|
59
|
+
N.map((r, c) => {
|
|
59
60
|
const o = d.get(r.label);
|
|
60
61
|
if (!o) return null;
|
|
61
|
-
const i =
|
|
62
|
-
return /* @__PURE__ */
|
|
62
|
+
const i = v[c % v.length], n = r.color || i.line, e = r.yMeasureUnit || R, s = e !== "%" && e !== "$" && e !== "none" ? e : void 0, p = e === "$" ? `$${x(o.value, void 0, u)}` : e === "%" ? `${x(o.value, void 0, u)}%` : x(o.value, s, u);
|
|
63
|
+
return /* @__PURE__ */ h(
|
|
63
64
|
"div",
|
|
64
65
|
{
|
|
65
66
|
className: "flex items-center gap-1.5 sm:gap-2 text-xs sm:text-sm whitespace-nowrap",
|
|
@@ -71,11 +72,11 @@ function T({
|
|
|
71
72
|
style: { backgroundColor: n }
|
|
72
73
|
}
|
|
73
74
|
),
|
|
74
|
-
/* @__PURE__ */
|
|
75
|
+
/* @__PURE__ */ h("span", { className: "text-muted-foreground whitespace-nowrap", children: [
|
|
75
76
|
r.label,
|
|
76
77
|
":"
|
|
77
78
|
] }),
|
|
78
|
-
/* @__PURE__ */ m("span", { className: "font-medium text-foreground whitespace-nowrap", children:
|
|
79
|
+
/* @__PURE__ */ m("span", { className: "font-medium text-foreground whitespace-nowrap", children: p })
|
|
79
80
|
]
|
|
80
81
|
},
|
|
81
82
|
r.label
|
|
@@ -86,5 +87,5 @@ function T({
|
|
|
86
87
|
);
|
|
87
88
|
}
|
|
88
89
|
export {
|
|
89
|
-
|
|
90
|
+
U as GraphTooltip
|
|
90
91
|
};
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { jsxs as Y, jsx as S } from "react/jsx-runtime";
|
|
2
|
-
import { createChart as
|
|
2
|
+
import { createChart as yt } from "lightweight-charts";
|
|
3
3
|
import * as ot from "react";
|
|
4
|
-
import { useRef as C, useState as
|
|
5
|
-
import { useIsMobile as
|
|
6
|
-
import { cn as
|
|
7
|
-
import { resolveCSSColor as
|
|
8
|
-
import { getDefaultOptions as
|
|
9
|
-
import { getXFormatter as
|
|
10
|
-
import { GraphCurrentValue as
|
|
11
|
-
import { GraphTooltip as
|
|
12
|
-
import { VertLine as
|
|
4
|
+
import { useRef as C, useState as ut, useEffect as O } from "react";
|
|
5
|
+
import { useIsMobile as Rt } from "../../hooks/use-media-query.js";
|
|
6
|
+
import { cn as mt } from "../../utils/cn.js";
|
|
7
|
+
import { resolveCSSColor as ft, generateColorsFromBase as rt } from "../../utils/colors.js";
|
|
8
|
+
import { getDefaultOptions as dt, getDefaultSeries as wt, getDefaultVerticalLine as Vt } from "./default-config.js";
|
|
9
|
+
import { getXFormatter as gt, createAdaptiveYAxisFormatter as Lt } from "./formatters.js";
|
|
10
|
+
import { GraphCurrentValue as Pt } from "./graph-current-value.js";
|
|
11
|
+
import { GraphTooltip as Mt } from "./graph-tooltip.js";
|
|
12
|
+
import { VertLine as At } from "./plugins/vertical-line.js";
|
|
13
13
|
const $ = [
|
|
14
14
|
{
|
|
15
15
|
line: "#02c39a",
|
|
@@ -52,7 +52,7 @@ const $ = [
|
|
|
52
52
|
bottom: "rgba(6, 182, 212, 0.04)"
|
|
53
53
|
}
|
|
54
54
|
];
|
|
55
|
-
function
|
|
55
|
+
function Yt({
|
|
56
56
|
series: o,
|
|
57
57
|
className: H,
|
|
58
58
|
showLegend: w = !1,
|
|
@@ -60,23 +60,24 @@ function Ht({
|
|
|
60
60
|
xMeasureUnit: V = "time",
|
|
61
61
|
yMeasureUnit: D = "token",
|
|
62
62
|
optionsOverrides: E,
|
|
63
|
-
verticalLineOptions: j
|
|
63
|
+
verticalLineOptions: j,
|
|
64
|
+
currentValueDecimals: nt
|
|
64
65
|
}) {
|
|
65
|
-
const x = C(null), b = C(/* @__PURE__ */ new Map()), W = C(!1), X = C(/* @__PURE__ */ new Set()),
|
|
66
|
+
const x = C(null), b = C(/* @__PURE__ */ new Map()), W = C(!1), X = C(/* @__PURE__ */ new Set()), at = C(0), lt = C(!0), Z = C(
|
|
66
67
|
null
|
|
67
|
-
),
|
|
68
|
+
), ht = C(null), A = C(null), _ = C(null), k = Rt(), L = ot.useMemo(() => o.flatMap((e) => e.data), [o]), pt = ot.useMemo(() => {
|
|
68
69
|
if (o.length > 0) {
|
|
69
70
|
const e = o[o.length - 1];
|
|
70
71
|
if (e.data.length > 0)
|
|
71
72
|
return e.data[e.data.length - 1];
|
|
72
73
|
}
|
|
73
|
-
}, [o]), [
|
|
74
|
-
if (!
|
|
74
|
+
}, [o]), [it, J] = ut(() => {
|
|
75
|
+
if (!pt) return;
|
|
75
76
|
const e = /* @__PURE__ */ new Map();
|
|
76
77
|
for (const r of o)
|
|
77
78
|
r.data.length > 0 && e.set(r.label, r.data[r.data.length - 1]);
|
|
78
79
|
return e;
|
|
79
|
-
}), [
|
|
80
|
+
}), [st, P] = ut(null);
|
|
80
81
|
O(() => {
|
|
81
82
|
const e = () => {
|
|
82
83
|
if (x.current && A.current) {
|
|
@@ -89,10 +90,10 @@ function Ht({
|
|
|
89
90
|
};
|
|
90
91
|
}, []), O(() => {
|
|
91
92
|
if (!_.current || W.current) return;
|
|
92
|
-
const e =
|
|
93
|
+
const e = dt(), r = ft(
|
|
93
94
|
"hsl(var(--foreground))",
|
|
94
95
|
"rgb(0, 0, 0)"
|
|
95
|
-
), l =
|
|
96
|
+
), l = yt(_.current, {
|
|
96
97
|
...e,
|
|
97
98
|
rightPriceScale: {
|
|
98
99
|
...e.rightPriceScale || {},
|
|
@@ -107,15 +108,15 @@ function Ht({
|
|
|
107
108
|
}, [k, E]), O(() => {
|
|
108
109
|
const e = x.current;
|
|
109
110
|
if (!e || o.length === 0) return;
|
|
110
|
-
const r = V === "time" ?
|
|
111
|
+
const r = V === "time" ? gt(V, L) : gt(V), l = L.map((t) => t.value), {
|
|
111
112
|
formatter: d,
|
|
112
113
|
updateVisibleRange: a,
|
|
113
114
|
updateLastValues: u
|
|
114
|
-
} =
|
|
115
|
-
Z.current = a,
|
|
115
|
+
} = Lt(l);
|
|
116
|
+
Z.current = a, ht.current = u;
|
|
116
117
|
const m = o.filter((t) => t.data.length > 0).map((t) => t.data[t.data.length - 1].value);
|
|
117
118
|
u(m);
|
|
118
|
-
const v =
|
|
119
|
+
const v = dt();
|
|
119
120
|
e.applyOptions({
|
|
120
121
|
localization: {
|
|
121
122
|
...v.localization || {},
|
|
@@ -133,7 +134,7 @@ function Ht({
|
|
|
133
134
|
minBarSpacing: 0
|
|
134
135
|
}
|
|
135
136
|
});
|
|
136
|
-
const M = (L.length > 0 ? Math.min(...L.map((t) => t.value)) : 0) < 0, y = L.some((t) => t.value === 0), f = !M && y, i = o.length > 1, c = i || k, s =
|
|
137
|
+
const M = (L.length > 0 ? Math.min(...L.map((t) => t.value)) : 0) < 0, y = L.some((t) => t.value === 0), f = !M && y, i = o.length > 1, c = i || k, s = ft(
|
|
137
138
|
"hsl(var(--foreground))",
|
|
138
139
|
"rgb(0, 0, 0)"
|
|
139
140
|
);
|
|
@@ -156,7 +157,7 @@ function Ht({
|
|
|
156
157
|
const n = b.current.get(t);
|
|
157
158
|
n && (e.removeSeries(n), b.current.delete(t));
|
|
158
159
|
}
|
|
159
|
-
const F =
|
|
160
|
+
const F = wt(), B = [];
|
|
160
161
|
let I = 0;
|
|
161
162
|
for (let t = 0; t < o.length; t++) {
|
|
162
163
|
const n = o[t], tt = $[t % $.length], G = n.color || tt.line;
|
|
@@ -180,10 +181,10 @@ function Ht({
|
|
|
180
181
|
p && (e.removeSeries(p), b.current.delete(n.label));
|
|
181
182
|
continue;
|
|
182
183
|
}
|
|
183
|
-
const
|
|
184
|
+
const Ct = (n.data.length > 0 ? Math.min(...n.data.map((p) => p.value)) : 0) < 0, St = n.data.some((p) => p.value === 0), xt = !Ct && St, et = i ? I === 0 ? "right" : `scale-${I}` : "right";
|
|
184
185
|
i && B.push({
|
|
185
186
|
priceScaleId: et || "right",
|
|
186
|
-
shouldPreventNegativeAxis:
|
|
187
|
+
shouldPreventNegativeAxis: xt,
|
|
187
188
|
seriesIndex: I
|
|
188
189
|
});
|
|
189
190
|
let z = b.current.get(n.label);
|
|
@@ -257,8 +258,8 @@ function Ht({
|
|
|
257
258
|
});
|
|
258
259
|
} catch {
|
|
259
260
|
}
|
|
260
|
-
const Q = new Set(o.map((t) => t.label)),
|
|
261
|
-
(
|
|
261
|
+
const Q = new Set(o.map((t) => t.label)), bt = Q.size !== X.current.size || [...Q].some((t) => !X.current.has(t)), vt = L.length !== at.current;
|
|
262
|
+
(lt.current || bt || vt || k) && (e.timeScale().fitContent(), lt.current = !1), X.current = Q, at.current = L.length;
|
|
262
263
|
const U = /* @__PURE__ */ new Map();
|
|
263
264
|
for (const t of o)
|
|
264
265
|
t.data.length > 0 && U.set(t.label, t.data[t.data.length - 1]);
|
|
@@ -359,9 +360,9 @@ function Ht({
|
|
|
359
360
|
}, [o]), O(() => {
|
|
360
361
|
const e = x.current, r = Array.from(b.current.values()), l = [];
|
|
361
362
|
if (e && r.length > 0 && j) {
|
|
362
|
-
const d =
|
|
363
|
+
const d = Vt(), a = r[0];
|
|
363
364
|
for (const u of j) {
|
|
364
|
-
const m = new
|
|
365
|
+
const m = new At(e, a, u.xCoordinate, {
|
|
365
366
|
...d,
|
|
366
367
|
...u.options || {}
|
|
367
368
|
});
|
|
@@ -376,7 +377,7 @@ function Ht({
|
|
|
376
377
|
}
|
|
377
378
|
};
|
|
378
379
|
}, [j]);
|
|
379
|
-
const K = o.length === 1,
|
|
380
|
+
const K = o.length === 1, ct = ot.useMemo(() => {
|
|
380
381
|
if (K && o.length > 0) {
|
|
381
382
|
const e = o[0];
|
|
382
383
|
if (e.data.length > 0)
|
|
@@ -387,31 +388,33 @@ function Ht({
|
|
|
387
388
|
"div",
|
|
388
389
|
{
|
|
389
390
|
ref: A,
|
|
390
|
-
className:
|
|
391
|
+
className: mt(
|
|
391
392
|
"relative z-[1] w-full h-full overflow-hidden p-0",
|
|
392
393
|
H
|
|
393
394
|
),
|
|
394
395
|
children: [
|
|
395
|
-
K &&
|
|
396
|
-
|
|
396
|
+
K && ct && /* @__PURE__ */ S(
|
|
397
|
+
Pt,
|
|
397
398
|
{
|
|
398
|
-
point:
|
|
399
|
+
point: ct,
|
|
399
400
|
xMeasureUnit: V,
|
|
400
|
-
yMeasureUnit: D
|
|
401
|
+
yMeasureUnit: D,
|
|
402
|
+
decimals: nt
|
|
401
403
|
}
|
|
402
404
|
),
|
|
403
|
-
|
|
404
|
-
|
|
405
|
+
it && st && /* @__PURE__ */ S(
|
|
406
|
+
Mt,
|
|
405
407
|
{
|
|
406
|
-
points:
|
|
408
|
+
points: it,
|
|
407
409
|
xMeasureUnit: V,
|
|
408
410
|
yMeasureUnit: D,
|
|
409
411
|
series: o,
|
|
410
|
-
position:
|
|
411
|
-
containerRef: A
|
|
412
|
+
position: st,
|
|
413
|
+
containerRef: A,
|
|
414
|
+
decimals: nt
|
|
412
415
|
}
|
|
413
416
|
),
|
|
414
|
-
w && /* @__PURE__ */ S(
|
|
417
|
+
w && /* @__PURE__ */ S(Ft, { series: o, onUnselect: q }),
|
|
415
418
|
/* @__PURE__ */ S(
|
|
416
419
|
"div",
|
|
417
420
|
{
|
|
@@ -423,7 +426,7 @@ function Ht({
|
|
|
423
426
|
}
|
|
424
427
|
);
|
|
425
428
|
}
|
|
426
|
-
function
|
|
429
|
+
function Ft({
|
|
427
430
|
series: o,
|
|
428
431
|
onUnselect: H
|
|
429
432
|
}) {
|
|
@@ -432,7 +435,7 @@ function At({
|
|
|
432
435
|
return /* @__PURE__ */ Y(
|
|
433
436
|
"div",
|
|
434
437
|
{
|
|
435
|
-
className:
|
|
438
|
+
className: mt(
|
|
436
439
|
"flex items-center gap-1.5 px-2 py-1 bg-background/80 backdrop-blur-sm rounded border border-border",
|
|
437
440
|
E && "opacity-50"
|
|
438
441
|
),
|
|
@@ -488,5 +491,5 @@ function At({
|
|
|
488
491
|
}
|
|
489
492
|
export {
|
|
490
493
|
$ as DEFAULT_SERIES_COLORS,
|
|
491
|
-
|
|
494
|
+
Yt as Graph
|
|
492
495
|
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { jsx as t, jsxs as f } from "react/jsx-runtime";
|
|
2
|
-
import { useMemo as d, useCallback as
|
|
3
|
-
import { toast as
|
|
4
|
-
import { useIsMobile as
|
|
5
|
-
import { RangeButtons as
|
|
2
|
+
import { useMemo as d, useCallback as O, useRef as D } from "react";
|
|
3
|
+
import { toast as $ } from "sonner";
|
|
4
|
+
import { useIsMobile as P } from "../../hooks/use-media-query.js";
|
|
5
|
+
import { RangeButtons as q } from "../buttons/range-buttons/range-buttons.js";
|
|
6
6
|
import { DEFAULT_SERIES_COLORS as i } from "../graph/graph.js";
|
|
7
|
-
import { GraphViewWithData as
|
|
8
|
-
import { GraphDropdown as
|
|
9
|
-
const
|
|
7
|
+
import { GraphViewWithData as J } from "../graph/graph-view.js";
|
|
8
|
+
import { GraphDropdown as K } from "./graph-dropdown.js";
|
|
9
|
+
const Q = ({ size: e = 16 }) => /* @__PURE__ */ f(
|
|
10
10
|
"svg",
|
|
11
11
|
{
|
|
12
12
|
width: e,
|
|
@@ -23,7 +23,7 @@ const K = ({ size: e = 16 }) => /* @__PURE__ */ f(
|
|
|
23
23
|
/* @__PURE__ */ t("path", { d: "M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3" })
|
|
24
24
|
]
|
|
25
25
|
}
|
|
26
|
-
),
|
|
26
|
+
), X = ({ size: e = 16 }) => /* @__PURE__ */ f(
|
|
27
27
|
"svg",
|
|
28
28
|
{
|
|
29
29
|
width: e,
|
|
@@ -41,7 +41,7 @@ const K = ({ size: e = 16 }) => /* @__PURE__ */ f(
|
|
|
41
41
|
]
|
|
42
42
|
}
|
|
43
43
|
);
|
|
44
|
-
function
|
|
44
|
+
function se({
|
|
45
45
|
data: e,
|
|
46
46
|
yMeasureUnit: n,
|
|
47
47
|
height: h = 306,
|
|
@@ -57,19 +57,20 @@ function ie({
|
|
|
57
57
|
onUnselectSeries: j,
|
|
58
58
|
graphsWithNoData: R,
|
|
59
59
|
loadingGraphs: V,
|
|
60
|
-
noDataMessage: A = "No data available for this graph"
|
|
60
|
+
noDataMessage: A = "No data available for this graph",
|
|
61
|
+
currentValueDecimals: B
|
|
61
62
|
}) {
|
|
62
|
-
const s = d(() => Array.isArray(e) ? e : e ? [e] : [], [e]), k = d(() => Array.isArray(e) && e.length > 1, [e]),
|
|
63
|
+
const s = d(() => Array.isArray(e) ? e : e ? [e] : [], [e]), k = d(() => Array.isArray(e) && e.length > 1, [e]), M = P(), _ = O(
|
|
63
64
|
(c, x) => {
|
|
64
|
-
|
|
65
|
+
$.error(A);
|
|
65
66
|
},
|
|
66
67
|
[A]
|
|
67
|
-
),
|
|
68
|
+
), F = d(() => {
|
|
68
69
|
if (n)
|
|
69
70
|
return Array.isArray(n) ? n[0] : n;
|
|
70
|
-
}, [n]),
|
|
71
|
+
}, [n]), T = /* @__PURE__ */ f("div", { className: "z-10 w-full flex flex-row flex-wrap sm:flex-nowrap items-center gap-2", children: [
|
|
71
72
|
/* @__PURE__ */ t("div", { children: b && w && g && /* @__PURE__ */ t(
|
|
72
|
-
|
|
73
|
+
K,
|
|
73
74
|
{
|
|
74
75
|
onSelected: b,
|
|
75
76
|
items: w,
|
|
@@ -77,22 +78,22 @@ function ie({
|
|
|
77
78
|
multiple: I,
|
|
78
79
|
graphsWithNoData: R,
|
|
79
80
|
loadingGraphs: V,
|
|
80
|
-
onNoDataSelected:
|
|
81
|
+
onNoDataSelected: _
|
|
81
82
|
}
|
|
82
83
|
) }),
|
|
83
84
|
/* @__PURE__ */ f("div", { className: "flex flex-row flex-nowrap justify-start sm:justify-end items-center flex-1", children: [
|
|
84
|
-
/* @__PURE__ */ t(
|
|
85
|
-
!
|
|
85
|
+
/* @__PURE__ */ t(q, { range: N, rangeList: L, setRange: E }),
|
|
86
|
+
!M && y && /* @__PURE__ */ t(
|
|
86
87
|
"button",
|
|
87
88
|
{
|
|
88
89
|
type: "button",
|
|
89
90
|
className: "px-2.5 py-1.5 flex min-w-[44px] min-h-[26px] justify-center items-center text-xs leading-[14px] font-medium text-center rounded-md border cursor-pointer transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring bg-muted border-muted text-muted-foreground hover:border-secondary ml-1.5",
|
|
90
91
|
onClick: y,
|
|
91
|
-
children: S ? /* @__PURE__ */ t(
|
|
92
|
+
children: S ? /* @__PURE__ */ t(X, { size: 16 }) : /* @__PURE__ */ t(Q, { size: 16 })
|
|
92
93
|
}
|
|
93
94
|
)
|
|
94
95
|
] })
|
|
95
|
-
] }), a = D(/* @__PURE__ */ new Map()), p = D(0),
|
|
96
|
+
] }), a = D(/* @__PURE__ */ new Map()), p = D(0), W = d(() => {
|
|
96
97
|
const c = Array.isArray(n) ? n : void 0;
|
|
97
98
|
return s.map((x, C) => {
|
|
98
99
|
const u = x?.title || `Series ${C + 1}`;
|
|
@@ -110,7 +111,7 @@ function ie({
|
|
|
110
111
|
}
|
|
111
112
|
a.current.set(u, o), p.current = (o + 1) % i.length;
|
|
112
113
|
}
|
|
113
|
-
const
|
|
114
|
+
const H = a.current.get(u) ?? 0, v = i[H % i.length];
|
|
114
115
|
return {
|
|
115
116
|
data: [...x?.data || []].sort((r, o) => {
|
|
116
117
|
const l = typeof r.time == "number" ? r.time : Number(r.time), m = typeof o.time == "number" ? o.time : Number(o.time);
|
|
@@ -132,7 +133,7 @@ function ie({
|
|
|
132
133
|
bottomColor: v.bottom
|
|
133
134
|
};
|
|
134
135
|
});
|
|
135
|
-
}, [s, n]),
|
|
136
|
+
}, [s, n]), z = k && s.length > 0 ? s.some((c) => !c) : !e;
|
|
136
137
|
return /* @__PURE__ */ t(
|
|
137
138
|
"div",
|
|
138
139
|
{
|
|
@@ -142,21 +143,22 @@ function ie({
|
|
|
142
143
|
},
|
|
143
144
|
className: "w-full",
|
|
144
145
|
children: /* @__PURE__ */ t(
|
|
145
|
-
|
|
146
|
+
J,
|
|
146
147
|
{
|
|
147
|
-
series:
|
|
148
|
-
loading:
|
|
149
|
-
toolbar:
|
|
148
|
+
series: W,
|
|
149
|
+
loading: z,
|
|
150
|
+
toolbar: T,
|
|
150
151
|
size: h ? "full" : "default",
|
|
151
152
|
containerClassName: "h-full",
|
|
152
153
|
showLegend: k,
|
|
153
154
|
onUnselectSeries: j,
|
|
154
|
-
yMeasureUnit:
|
|
155
|
+
yMeasureUnit: F,
|
|
156
|
+
currentValueDecimals: B
|
|
155
157
|
}
|
|
156
158
|
)
|
|
157
159
|
}
|
|
158
160
|
);
|
|
159
161
|
}
|
|
160
162
|
export {
|
|
161
|
-
|
|
163
|
+
se as TradingView
|
|
162
164
|
};
|
|
@@ -5,9 +5,14 @@ export interface GraphCurrentValueProps {
|
|
|
5
5
|
xMeasureUnit: XMeasureUnits;
|
|
6
6
|
yMeasureUnit: YMeasureUnits;
|
|
7
7
|
className?: string;
|
|
8
|
+
/**
|
|
9
|
+
* Number of decimal places for current value display.
|
|
10
|
+
* If 0, rounds to whole numbers. Default is 4.
|
|
11
|
+
*/
|
|
12
|
+
decimals?: number;
|
|
8
13
|
}
|
|
9
14
|
/**
|
|
10
15
|
* GraphCurrentValue component displays the current value in single mode
|
|
11
16
|
* without background, border, or legend - just date and value
|
|
12
17
|
*/
|
|
13
|
-
export declare function GraphCurrentValue({ point, xMeasureUnit, yMeasureUnit, className, }: GraphCurrentValueProps): React.ReactElement;
|
|
18
|
+
export declare function GraphCurrentValue({ point, xMeasureUnit, yMeasureUnit, className, decimals, }: GraphCurrentValueProps): React.ReactElement;
|
|
@@ -16,9 +16,14 @@ export interface GraphTooltipProps {
|
|
|
16
16
|
};
|
|
17
17
|
/** Container element to constrain tooltip within bounds */
|
|
18
18
|
containerRef?: React.RefObject<HTMLElement | null>;
|
|
19
|
+
/**
|
|
20
|
+
* Number of decimal places for value display.
|
|
21
|
+
* If 0, rounds to whole numbers. Default is 4.
|
|
22
|
+
*/
|
|
23
|
+
decimals?: number;
|
|
19
24
|
}
|
|
20
25
|
/**
|
|
21
26
|
* GraphTooltip component displays the current value and time on the graph
|
|
22
27
|
* Supports single or multiple series
|
|
23
28
|
*/
|
|
24
|
-
export declare function GraphTooltip({ points, series, xMeasureUnit, yMeasureUnit, className, position, containerRef, }: GraphTooltipProps): React.ReactElement | null;
|
|
29
|
+
export declare function GraphTooltip({ points, series, xMeasureUnit, yMeasureUnit, className, position, containerRef, decimals, }: GraphTooltipProps): React.ReactElement | null;
|
|
@@ -38,11 +38,16 @@ export interface GraphProps {
|
|
|
38
38
|
xCoordinate: Time;
|
|
39
39
|
options?: VerticalLineOptions;
|
|
40
40
|
}>;
|
|
41
|
+
/**
|
|
42
|
+
* Number of decimal places for current value display.
|
|
43
|
+
* If 0, rounds to whole numbers. Default is 4.
|
|
44
|
+
*/
|
|
45
|
+
currentValueDecimals?: number;
|
|
41
46
|
}
|
|
42
47
|
/**
|
|
43
48
|
* Graph component that renders a chart using lightweight-charts library
|
|
44
49
|
* with support for area series, custom tooltips, and vertical line annotations
|
|
45
50
|
* Supports single or multiple series with different colors and legends
|
|
46
51
|
*/
|
|
47
|
-
export declare function Graph({ series, className, showLegend, onUnselectSeries, xMeasureUnit, yMeasureUnit, optionsOverrides, verticalLineOptions, }: GraphProps): React.ReactElement;
|
|
52
|
+
export declare function Graph({ series, className, showLegend, onUnselectSeries, xMeasureUnit, yMeasureUnit, optionsOverrides, verticalLineOptions, currentValueDecimals, }: GraphProps): React.ReactElement;
|
|
48
53
|
export {};
|
|
@@ -52,6 +52,11 @@ export interface TradingViewProps<T extends string = string> {
|
|
|
52
52
|
loadingGraphs?: Set<T>;
|
|
53
53
|
/** Message to show when user selects a graph with no data */
|
|
54
54
|
noDataMessage?: string;
|
|
55
|
+
/**
|
|
56
|
+
* Number of decimal places for current value display.
|
|
57
|
+
* If 0, rounds to whole numbers. Default is 8 (full precision).
|
|
58
|
+
*/
|
|
59
|
+
currentValueDecimals?: number;
|
|
55
60
|
}
|
|
56
61
|
/**
|
|
57
62
|
* TradingView — comprehensive charting component with graph selection and time range controls.
|
|
@@ -108,4 +113,4 @@ export interface TradingViewProps<T extends string = string> {
|
|
|
108
113
|
* />
|
|
109
114
|
* ```
|
|
110
115
|
*/
|
|
111
|
-
export declare function TradingView<T extends string = string>({ data, yMeasureUnit, height, defaultGraph, onGraphSelected, graphs, isMultipleSelect, range, rangeList, setRange, onGraphExpanded, isGraphExpanded, onUnselectSeries, graphsWithNoData, loadingGraphs, noDataMessage, }: TradingViewProps<T>): React.ReactElement;
|
|
116
|
+
export declare function TradingView<T extends string = string>({ data, yMeasureUnit, height, defaultGraph, onGraphSelected, graphs, isMultipleSelect, range, rangeList, setRange, onGraphExpanded, isGraphExpanded, onUnselectSeries, graphsWithNoData, loadingGraphs, noDataMessage, currentValueDecimals, }: TradingViewProps<T>): React.ReactElement;
|