@gearbox-protocol/permissionless-ui 1.15.4 → 1.16.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/dist/cjs/components/graph/graph-view.cjs +1 -1
- package/dist/cjs/components/graph/graph.cjs +1 -1
- package/dist/cjs/components/health-factor/health-factor.cjs +1 -1
- package/dist/cjs/components/trading-view/graph-dropdown.cjs +1 -1
- package/dist/cjs/components/trading-view/trading-view.cjs +1 -1
- package/dist/cjs/utils/format-money.cjs +1 -1
- package/dist/cjs/utils/format-number.cjs +1 -1
- package/dist/esm/components/graph/graph-view.js +73 -72
- package/dist/esm/components/graph/graph.js +243 -218
- package/dist/esm/components/health-factor/health-factor.js +1 -1
- package/dist/esm/components/trading-view/graph-dropdown.js +20 -19
- package/dist/esm/components/trading-view/trading-view.js +48 -48
- package/dist/esm/utils/format-money.js +8 -8
- package/dist/esm/utils/format-number.js +55 -47
- package/dist/types/utils/format-money.d.ts +3 -1
- package/dist/types/utils/format-number.d.ts +4 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),b=require("class-variance-authority"),u=require("react"),w=require("../../utils/cn.cjs"),N=require("./graph.cjs");function k(t){const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const s in t)if(s!=="default"){const r=Object.getOwnPropertyDescriptor(t,s);Object.defineProperty(a,s,r.get?r:{enumerable:!0,get:()=>t[s]})}}return a.default=t,Object.freeze(a)}const y=k(u),v=b.cva("relative w-full overflow-hidden rounded-lg border-border border bg-card text-card-foreground",{variants:{variant:{default:"shadow",elevated:"shadow-lg",outlined:"border-2",ghost:"border-0 shadow-none"},size:{sm:"h-48 sm:h-64",default:"h-64 sm:h-96",lg:"h-96 sm:h-[32rem]",xl:"h-[32rem] sm:h-[48rem]",full:"h-full"},padding:{none:"p-0",sm:"p-2",default:"p-4 sm:p-6",lg:"p-6"}},defaultVariants:{variant:"default",size:"default",padding:"default"}}),g=y.forwardRef(({className:t,variant:a,size:s,padding:r,title:l,description:i,toolbar:n,loading:c=!1,emptyMessage:o,error:d,children:h,...m},f)=>{const x=l||i||n;return e.jsxs("div",{ref:f,className:w.cn("flex flex-col",v({variant:a,size:s,padding:r,className:t})),...m,children:[x&&e.jsxs("div",{className:"mb-4 flex items-start justify-between gap-4 flex-shrink-0",children:[(l||i)&&e.jsxs("div",{className:"flex-1",children:[l&&e.jsx("h3",{className:"text-base sm:text-lg font-semibold leading-none tracking-tight",children:l}),i&&e.jsx("p",{className:"mt-1 text-xs sm:text-sm text-muted-foreground",children:i})]}),n&&e.jsx("div",{className:"flex-shrink-0 w-full",children:n})]}),e.jsxs("div",{className:"relative flex-1 w-full min-h-0",children:[c&&e.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-transparent backdrop-blur-sm",children:e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"}),e.jsx("span",{className:"text-xs sm:text-sm text-muted-foreground",children:"Loading..."})]})}),d&&e.jsx("div",{className:"flex h-full items-center justify-center",children:e.jsxs("div",{className:"flex flex-col items-center gap-2 text-destructive",children:[e.jsx("svg",{className:"h-12 w-12",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","aria-hidden":"true",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),e.jsx("span",{className:"text-xs sm:text-sm font-medium",children:d})]})}),!d&&!h&&o&&e.jsx("div",{className:"flex h-full items-center justify-center",children:e.jsxs("div",{className:"flex flex-col items-center gap-2 text-muted-foreground",children:[e.jsx("svg",{className:"h-12 w-12",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","aria-hidden":"true",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20 13V6a2 2 0 00-2-2H6a2 2 0 00-2 2v7m16 0v5a2 2 0 01-2 2H6a2 2 0 01-2-2v-5m16 0h-2.586a1 1 0 00-.707.293l-2.414 2.414a1 1 0 01-.707.293h-3.172a1 1 0 01-.707-.293l-2.414-2.414A1 1 0 006.586 13H4"})}),e.jsx("span",{className:"text-xs sm:text-sm",children:o})]})}),!d&&h]})]})});g.displayName="GraphView";function V({series:t,onUnselectSeries:a,loading:s,title:r,description:l,toolbar:i,emptyMessage:n="No data available",error:c,containerClassName:o,variant:d,size:h,padding:m,...f}){t.length>0&&t.some(p=>p.data.length>0),t.length>0&&t.some(p=>p.data.length>0);const x=!s&&t.length===0,j=t.length>0;return e.jsx(g,{className:o,variant:d,size:h,padding:m,title:r,description:l,toolbar:i,loading:s,error:c,emptyMessage:x?n:void 0,children:j&&!c&&e.jsx(N.Graph,{series:t,...a?{onUnselectSeries:a}:{},...f})})}function R(t=0){const a=u.useRef(null),s=u.useRef(null),[r,l]=u.useState(null);return u.useEffect(()=>{const i=()=>{if(a.current&&s.current){const o=s.current.clientWidth,d=a.current.clientWidth;l(o-d-t)}},n=s.current,c=n?new ResizeObserver(i):null;return n&&c?.observe(n),()=>{n&&c?.unobserve(n)}},[t]),{graphWidth:r,parentRef:s,asideRef:a}}exports.GraphView=g;exports.GraphViewWithData=V;exports.graphViewVariants=v;exports.useGraphAside=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 m=require("react/jsx-runtime"),me=require("lightweight-charts"),i=require("react"),he=require("../../hooks/use-media-query.cjs"),se=require("../../utils/cn.cjs"),B=require("../../utils/colors.cjs"),$=require("./default-config.cjs"),ee=require("./formatters.cjs"),pe=require("./graph-current-value.cjs"),be=require("./graph-tooltip.cjs"),ve=require("./plugins/vertical-line.cjs");function Ce(e){const L=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const h in e)if(h!=="default"){const k=Object.getOwnPropertyDescriptor(e,h);Object.defineProperty(L,h,k.get?k:{enumerable:!0,get:()=>e[h]})}}return L.default=e,Object.freeze(L)}const te=Ce(i),G=[{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 Se({series:e,className:L,showLegend:h=!1,onUnselectSeries:k,xMeasureUnit:P="time",yMeasureUnit:E="token",optionsOverrides:A,verticalLineOptions:D}){const S=i.useRef(null),x=i.useRef(new Map),X=i.useRef(!1),oe=i.useRef(new Set),re=i.useRef(null),ne=i.useRef(!0),V=i.useRef(null),W=i.useRef(null),z=he.useIsMobile(),T=te.useMemo(()=>e.flatMap(t=>t.data),[e]),ce=te.useMemo(()=>{if(e.length>0){const t=e[e.length-1];if(t.data.length>0)return t.data[t.data.length-1]}},[e]),[ae,Y]=i.useState(()=>{if(!ce)return;const t=new Map;for(const n of e)n.data.length>0&&t.set(n.label,n.data[n.data.length-1]);return t}),[le,M]=i.useState(null);i.useEffect(()=>{const t=()=>{if(S.current&&V.current){const u=V.current.clientWidth,a=V.current.clientHeight;S.current.resize(u,a),S.current.timeScale().fitContent()}},n=V.current,l=n?new ResizeObserver(t):null;return n&&l?.observe(n),()=>{n&&l?.unobserve(n)}},[]),i.useEffect(()=>{if(!W.current||X.current)return;const t=$.getDefaultOptions(),n=B.resolveCSSColor("hsl(var(--foreground))","rgb(0, 0, 0)"),l=me.createChart(W.current,{...t,rightPriceScale:{...t.rightPriceScale||{},visible:!z,textColor:n},...A});return S.current=l,X.current=!0,()=>{l.remove(),S.current=null,X.current=!1,x.current.clear()}},[z,A]),i.useEffect(()=>{const t=S.current;if(!t||e.length===0)return;const n=P==="time"?ee.getXFormatter(P,T):ee.getXFormatter(P),l=ee.getYFormatter(E),u=$.getDefaultOptions();t.applyOptions({localization:{...u.localization||{},timeFormatter:n?(o=>n(parseFloat(o),void 0)):void 0},timeScale:{...u.timeScale||{},tickMarkFormatter:n?(o=>n(parseFloat(o),void 0)):void 0,minBarSpacing:0}});const g=(T.length>0?Math.min(...T.map(o=>o.value)):0)<0,R=T.some(o=>o.value===0),N=!g&&R,s=e.length>1,j=s||z,y=B.resolveCSSColor("hsl(var(--foreground))","rgb(0, 0, 0)");t.applyOptions({rightPriceScale:{...u.rightPriceScale||{},visible:!z,textColor:y,...N&&{scaleMargins:{top:.3,bottom:0}}}});const b=new Set(x.current.keys()),c=new Set(e.map(o=>o.label));for(const o of b)if(!c.has(o)){const r=x.current.get(o);r&&(t.removeSeries(r),x.current.delete(o))}const v=$.getDefaultSeries(),f=[];let C=0;for(let o=0;o<e.length;o++){const r=e[o],K=G[o%G.length],I=r.color||K.line;let O,_;if(r.color)if(r.topColor&&r.bottomColor)O=r.topColor,_=r.bottomColor;else if(r.topColor){const d=B.generateColorsFromBase(I);O=r.topColor,_=d.bottomColor}else if(r.bottomColor)O=B.generateColorsFromBase(I).topColor,_=r.bottomColor;else{const d=B.generateColorsFromBase(I);O=d.topColor,_=d.bottomColor}else O=r.topColor||K.top,_=r.bottomColor||K.bottom;if(r.data.length===0){const d=x.current.get(r.label);d&&(t.removeSeries(d),x.current.delete(r.label));continue}const fe=(r.data.length>0?Math.min(...r.data.map(d=>d.value)):0)<0,ge=r.data.some(d=>d.value===0),de=!fe&&ge,U=s?C===0?void 0:`scale-${C}`:void 0;s&&f.push({priceScaleId:U||"right",shouldPreventNegativeAxis:de,seriesIndex:C});let q=x.current.get(r.label);q?(q.applyOptions({lineColor:I,topColor:O,bottomColor:_,priceScaleId:U}),q.setData(r.data)):(q=t.addAreaSeries({...v,lineColor:I,topColor:O,bottomColor:_,priceScaleId:U,priceFormat:{type:"custom",formatter:d=>l(parseFloat(d.toString()),void 0,"short")}}),q.setData(r.data),x.current.set(r.label,q)),C++}if(s&&f.length>0)for(const o of f)try{const r=t.priceScale(o.priceScaleId);r&&r.applyOptions({visible:!j,autoScale:!0,scaleMargins:{top:.1,bottom:.1,...o.shouldPreventNegativeAxis&&{top:.3,bottom:0}},alignLabels:!0,borderVisible:!0,borderColor:"rgba(224, 227, 235, 0.1)",entireTextOnly:!1,textColor:y})}catch(r){console.warn(`Failed to configure price scale ${o.priceScaleId} for series ${o.seriesIndex}:`,r)}let p=null;if(T.length>0){const o=T.map(r=>typeof r.time=="number"?r.time:Number(r.time));p={from:Math.min(...o),to:Math.max(...o)}}const w=new Set(e.map(o=>o.label)),H=oe.current,Q=w.size!==H.size||[...w].some(o=>!H.has(o)),F=re.current,ue=p&&F&&(Math.abs(p.from-F.from)>(F.to-F.from)*.1||Math.abs(p.to-F.to)>(F.to-F.from)*.1);(ne.current||Q||ue||!F)&&(requestAnimationFrame(()=>{S.current&&S.current.timeScale().fitContent()}),ne.current=!1),oe.current=w,re.current=p;const J=new Map;for(const o of e)o.data.length>0&&J.set(o.label,o.data[o.data.length-1]);Y(J.size>0?J:void 0)},[e,T,P,E,z]),i.useEffect(()=>{const t=S.current;if(!t||e.length===0)return;const n=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 u=a=>{const{time:g=l,seriesData:R,point:N}=a||{},s=Array.from(x.current.values());if(!N||!g){const b=new Map;for(const c of e)c.data.length>0&&b.set(c.label,c.data[c.data.length-1]);if(Y(b.size>0?b:void 0),n)M(null);else if(s[0]&&l){const v=t.timeScale().timeToCoordinate(l),f=e[0];if(f.data.length>0){const C=f.data[f.data.length-1].value,p=s[0].priceToCoordinate(C);v!==null&&p!==null&&M({x:v,y:p})}}return}const j=new Map;let y;for(let b=0;b<e.length;b++){const c=e[b],v=s[b];if(!v)continue;const f=R?.get(v),C=f&&"value"in f?f.value:void 0,p=c.data[c.data.length-1],w=C!==void 0?C:p?.value??0;b===0&&(y=w),j.set(c.label,{value:w,time:g})}if(Y(j),y!==void 0&&s[0]){const c=t.timeScale().timeToCoordinate(g),v=s[0].priceToCoordinate(y);if(c!==null&&v!==null){const f=V.current;if(f){const C=f.querySelector(".LightweightChart");if(C){const p=C.getBoundingClientRect(),w=f.getBoundingClientRect(),H=c+(p.left-w.left),Q=v+(p.top-w.top);M({x:H,y:Q})}else M({x:c,y:v})}else M({x:c,y:v})}else M(null)}else M(null)};return t.subscribeCrosshairMove(u),n||requestAnimationFrame(()=>{const a=Array.from(x.current.values());if(a[0]&&l&&e[0]?.data.length>0){const R=t.timeScale().timeToCoordinate(l),N=e[0].data[e[0].data.length-1].value,s=a[0].priceToCoordinate(N);R!==null&&s!==null&&M({x:R,y:s})}}),()=>{t.unsubscribeCrosshairMove(u)}},[e]),i.useEffect(()=>{const t=S.current;if(!t||e.length===0)return;const n=t.timeScale(),l=Math.max(...e.map(a=>a.data.length)),u=()=>{if(l===0)return;const a=n.getVisibleLogicalRange();if(!a)return;const g={from:0,to:l-1},R=typeof a.from=="number"?a.from:0,N=typeof a.to=="number"?a.to:l-1,s=.01;let j=!1;const y={...a};R<g.from-s&&(y.from=g.from,j=!0),N>g.to+s&&(y.to=g.to,j=!0),j&&n.setVisibleLogicalRange(y)};return n.subscribeVisibleLogicalRangeChange(u),()=>{n.unsubscribeVisibleLogicalRangeChange(u)}},[e]),i.useEffect(()=>{const t=S.current,n=Array.from(x.current.values()),l=[];if(t&&n.length>0&&D){const u=$.getDefaultVerticalLine(),a=n[0];for(const g of D){const R=new ve.VertLine(t,a,g.xCoordinate,{...u,...g.options||{}});a.attachPrimitive(R),l.push(R)}}return()=>{if(n.length>0){const u=n[0];for(const a of l)u.detachPrimitive(a)}}},[D]);const Z=e.length===1,ie=te.useMemo(()=>{if(Z&&e.length>0){const t=e[0];if(t.data.length>0)return t.data[t.data.length-1]}},[Z,e]);return m.jsxs("div",{ref:V,className:se.cn("relative z-[1] w-full h-full overflow-hidden p-0",L),children:[Z&&ie&&m.jsx(pe.GraphCurrentValue,{point:ie,xMeasureUnit:P,yMeasureUnit:E}),ae&&le&&m.jsx(be.GraphTooltip,{points:ae,xMeasureUnit:P,yMeasureUnit:E,series:e,position:le,containerRef:V}),h&&m.jsx(xe,{series:e,onUnselect:k}),m.jsx("div",{ref:W,className:"LightweightChart w-full h-full overflow-hidden"})]})}function xe({series:e,onUnselect:L}){return m.jsx("div",{className:"absolute top-0 left-2 z-[10] flex flex-wrap gap-2",children:e.map((h,k)=>{const P=G[k%G.length],E=h.color||P.line,A=h.data.length===0;return m.jsxs("div",{className:se.cn("flex items-center gap-1.5 px-2 py-1 bg-background/80 backdrop-blur-sm rounded border border-border",A&&"opacity-50"),children:[m.jsx("div",{className:"w-3 h-3 rounded-sm",style:{backgroundColor:E}}),m.jsxs("span",{className:"text-[10px] sm:text-xs font-medium text-foreground",children:[h.label,A&&" (no data)"]}),L&&m.jsx("button",{type:"button",onClick:D=>{D.stopPropagation(),L(h.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 ${h.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"})]})})]},h.label)})})}exports.DEFAULT_SERIES_COLORS=G;exports.Graph=Se;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const H=require("react/jsx-runtime");require("react");const _=require("../../utils/cn.cjs");require("sonner");require("@gearbox-protocol/sdk");const n=require("../../utils/format-money.cjs"),u=15e3,c=11e3,q=10500,s=t=>{if(!t)return;const e=Number(t);return e>=u?"good":e>c?"medium":e>q?"bad":e>n.PERCENTAGE_FACTOR?"critical":"liquidation"};function C({value:t,debt:e,decimals:a=3,zone:r,showColor:l=!0,className:d,...m}){const o=e!==void 0&&e===0n,i=(()=>{if(!o)return r??s(t)})(),f=()=>{if(!l||i===void 0)return"";switch(i){case"good":return"text-green-600";case"medium":return"text-yellow-600";case"bad":return"text-orange-500";case"critical":case"liquidation":return"text-destructive";default:return""}},g=()=>{if(o)return"N/A";const F=Number(t)/n.PERCENTAGE_FACTOR,A=n.formatPercentAmount(F,a);return String(A)};return H.jsx("div",{className:_.cn("font-medium",f(),d),...m,children:g()})}exports.BAD_HF=c;exports.GOOD_HF=u;exports.HealthFactor=C;exports.getHFZones=s;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const H=require("react/jsx-runtime");require("react");const _=require("../../utils/cn.cjs");require("sonner");require("@gearbox-protocol/sdk");const n=require("../../utils/format-money.cjs"),u=15e3,c=11e3,q=10500,s=t=>{if(!t)return;const e=Number(t);return e>=u?"good":e>c?"medium":e>q?"bad":e>n.PERCENTAGE_FACTOR?"critical":"liquidation"};function C({value:t,debt:e,decimals:a=3,zone:r,showColor:l=!0,className:d,...m}){const o=e!==void 0&&e===0n,i=(()=>{if(!o)return r??s(t)})(),f=()=>{if(!l||i===void 0)return"";switch(i){case"good":return"text-green-600";case"medium":return"text-yellow-600";case"bad":return"text-orange-500";case"critical":case"liquidation":return"text-destructive";default:return""}},g=()=>{if(o)return"N/A";const F=Number(t)/n.PERCENTAGE_FACTOR,A=n.formatPercentAmount(F,a,!1);return String(A)};return H.jsx("div",{className:_.cn("font-medium",f(),d),...m,children:g()})}exports.BAD_HF=c;exports.GOOD_HF=u;exports.HealthFactor=C;exports.getHFZones=s;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react/jsx-runtime"),w=require("lucide-react"),t=require("react"),o=require("../select/select.cjs");function k({items:i,defaultItem:r,onSelected:g,multiple:a=!1,graphsWithNoData:A,loadingGraphs:v,onNoDataSelected:S}){const _=()=>{if(a){const n=Array.isArray(r)?r:[r];return n.length===0?"":String(n[0].value)}const e=Array.isArray(r)?r[0]:r;return String(e?.value||"")},C=()=>{if(a){const n=Array.isArray(r)?r:[r];return new Set(n.map(s=>s.value))}const e=Array.isArray(r)?r[0]:r;return new Set([e?.value].filter(Boolean))},[u,b]=t.useState(C),[d,y]=t.useState(_()),[p,N]=t.useState(!1),f=t.useRef(!1);t.useEffect(()=>{if(a){const e=Array.isArray(r)?r:[r],n=new Set(e.map(s=>s.value));b(n),e.length>0&&y(String(e[0].value))}else{const e=Array.isArray(r)?r[0]:r;e?.value&&y(String(e.value))}},[r,a]);const O=t.useCallback(e=>{if(!e&&a&&f.current){f.current=!1;return}N(e)},[a]),j=t.useCallback(e=>{const n=i.find(s=>String(s.value)===e);if(n&&!v?.has(n.value)){if(A?.has(n.value)&&!(a&&u.has(n.value))){S&&S(n.value,n.label);return}a?(f.current=!0,b(s=>{const c=new Set(s);if(c.has(n.value)){if(c.size<=1)return s;c.delete(n.value)}else c.add(n.value);return g(Array.from(c)),c})):(y(e),g(n.value))}},[a,g,i,A,v,S,u]),x=t.useMemo(()=>{if(!a){const s=i.find(h=>String(h.value)===d),c=Array.isArray(r)?r[0]:r;return s||c}const e=Array.from(u).map(s=>i.find(c=>c.value===s)).filter(s=>!!s);return e.length===0?(Array.isArray(r)?r:[r])[0]:e.length===1?e[0]:{value:e[0].value,label:`${e.length} selected`}},[a,r,i,u,d]),R=t.useMemo(()=>a?"__multiple_placeholder__":d,[a,d]);return!i.length||i.length===1&&!a?l.jsx("div",{className:"flex items-center",style:{width:"max-content"},children:l.jsx("div",{className:"text-xl leading-6",children:x.label})}):l.jsxs(o.Select,{value:R,onValueChange:j,open:p,onOpenChange:O,children:[l.jsx(o.SelectTrigger,{className:"w-auto min-w-[16rem]",children:l.jsx(o.SelectValue,{children:x.label})}),l.jsxs(o.SelectContent,{className:"min-w-[16rem]",children:[a&&l.jsx(o.SelectItem,{value:"__multiple_placeholder__",className:"hidden",disabled:!0,children:x.label}),i.map((e,n)=>{const s=a&&u.has(e.value),c=v?.has(e.value),h=c;return l.jsx(o.SelectItem,{value:String(e.value),disabled:h,onSelect:V=>{a&&V.preventDefault(),j(String(e.value))},className:h?"opacity-50 cursor-not-allowed":"",children:l.jsxs("div",{className:"flex items-center gap-2",children:[a&&l.jsx("span",{className:`flex h-4 w-4 items-center justify-center rounded-[4px] border border-primary shadow transition-colors ${s?"bg-primary text-primary-foreground":""}`,children:s&&l.jsx(w.Check,{className:"h-4 w-4"})}),e.label,c&&l.jsx(w.Loader2,{className:"ml-1 h-4 w-4 animate-spin text-muted-foreground"})]})},`graph-item-${n}-${String(e.value)}`)})]})]})}exports.GraphDropdown=k;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),i=require("react"),F=require("sonner"),B=require("../../hooks/use-media-query.cjs"),W=require("../buttons/range-buttons/range-buttons.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),i=require("react"),F=require("sonner"),B=require("../../hooks/use-media-query.cjs"),W=require("../buttons/range-buttons/range-buttons.cjs"),l=require("../graph/graph.cjs"),z=require("../graph/graph-view.cjs"),H=require("./graph-dropdown.cjs"),P=({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"})]}),$=({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 Q({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"}){const a=i.useMemo(()=>Array.isArray(t)?t:t?[t]:[],[t]),S=i.useMemo(()=>Array.isArray(t)&&t.length>1,[t]),k=B.useIsMobile(),O=i.useCallback((c,f)=>{F.toast.error(j)},[j]),N=i.useMemo(()=>{if(n)return Array.isArray(n)?n[0]:n},[n]),M=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(H.GraphDropdown,{onSelected:v,items:b,defaultItem:g,multiple:y,graphsWithNoData:D,loadingGraphs:I,onNoDataSelected:O})}),e.jsxs("div",{className:"flex flex-row flex-nowrap justify-start sm:justify-end items-center flex-1",children:[e.jsx(W.RangeButtons,{range:A,rangeList:E,setRange:L}),!k&&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($,{size:16}):e.jsx(P,{size:16})})]})]}),u=i.useRef(new Map),x=i.useRef(0),T=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 V=u.current.get(d)??0,p=l.DEFAULT_SERIES_COLORS[V%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]),q=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(z.GraphViewWithData,{series:T,loading:q,toolbar:M,size:h?"full":"default",containerClassName:"h-full",showLegend:S,onUnselectSeries:C,yMeasureUnit:N})})}exports.TradingView=Q;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("@gearbox-protocol/sdk"),p=10000000000000000n;function E(t){return BigInt(t.toFixed(18).replace(".",""))}function T(t,e){const n=typeof t=="number"&&t<0||typeof t=="bigint"&&t<0n?"-":"",o=typeof t=="number"?E(Math.abs(t)):u.BigIntMath.abs(t),a=o<p&&o>0n,m=a?"0.01":u.formatBN(o,u.WAD_DECIMALS_POW,e),c=`${n}$${m}`;return a?`< ${c}`:c}const N=1e4;function i(t,e,r=!0){const n=typeof t=="number"?t:Number(t);return Number.isNaN(n)||n===void 0||n===null?"0":n===0?0:r&&n>N?n.toExponential(e):n.toFixed(e)}function l(t,e=2){return`${i(t,e)}%`}const s=1e4;function A(t,e=2){const r=Number(t)/Number(s);return`${i(r,e)}%`}const f=1000n;function b(t,e=1){return t===void 0?"-":`${(t/Number(f)).toFixed(e)}%`}exports.PERCENTAGE_FACTOR=s;exports.SLIPPAGE_DECIMALS=f;exports.formatMoney=T;exports.formatPercentAmount=i;exports.percentTemplate=l;exports.percentageTemplate=A;exports.slippageTemplate=b;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=1e-10,h=1e-4,D=1e11;function m(t){const e=Math.abs(t);return e<10?4:e<100?2:1}function u(t){return t.replace(/\.?0+$/,"")}function S(t,e={}){const{format:i="full",minimumFractionDigits:r=0,maximumFractionDigits:o,maxExponentialThreshold:l=D,adaptiveDecimals:a=!1}=e,s=o!==void 0?o:i==="short"?1:0,f=Math.abs(t);if(i==="short"){if(f>=5e8){const n=t/1e9,c=a?m(n):s;return`${u(n.toFixed(c))}B`}if(f>=1e6){const n=t/1e6,c=a?m(n):s;return`${u(n.toFixed(c))}M`}if(f>=1e3){const n=t/1e3,c=a?m(n):s;return`${u(n.toFixed(c))}K`}}return l&&f>l?t.toExponential(2):new Intl.NumberFormat("en-US",{minimumFractionDigits:r,maximumFractionDigits:s}).format(t)}function F(t,e){const i=Math.abs(t);if(i>=1){const r=10**e;return(Math.floor(t*r)/r).toFixed(e).replace(/\.?0+$/,"")}if(i>0){const r=Math.floor(Math.log10(i)),o=Math.max(e,Math.abs(r)+e),a=Math.min(o,10);return t.toFixed(a).replace(/\.?0+$/,"")}return"0"}function M(t){return Math.abs(t)<d}function x(t){const e=Math.abs(t);return e<d&&e>0}function b(t,e){if(!x(t))return null;const i=`<${h}`;return e?`${i}${e}`:i}const g={EPSILON:d,MIN_DISPLAY_THRESHOLD:h,MAX_EXPONENTIAL_THRESHOLD:D};function p(t,e=2,i=6){if(!Number.isFinite(t))return"∞";const r=1/10**e;return t<r&&t!==0?t.toFixed(i).replace(/\.?0+$/,""):t>1?new Intl.NumberFormat("en-US",{minimumFractionDigits:e,maximumFractionDigits:e}).format(t):t.toFixed(e)}exports.FORMAT_CONSTANTS=g;exports.formatNumberWithSuffix=S;exports.formatPrice=p;exports.formatSmallValue=b;exports.getAdaptiveDecimals=m;exports.isBelowDisplayThreshold=x;exports.isEffectivelyZero=M;exports.toSignificantDigits=F;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { cva as
|
|
3
|
-
import * as
|
|
4
|
-
import { useRef as v, useState as
|
|
5
|
-
import { cn as
|
|
6
|
-
import { Graph as
|
|
7
|
-
const V =
|
|
1
|
+
import { jsxs as o, jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { cva as b } from "class-variance-authority";
|
|
3
|
+
import * as w from "react";
|
|
4
|
+
import { useRef as v, useState as k, useEffect as j } from "react";
|
|
5
|
+
import { cn as W } from "../../utils/cn.js";
|
|
6
|
+
import { Graph as R } from "./graph.js";
|
|
7
|
+
const V = b(
|
|
8
8
|
"relative w-full overflow-hidden rounded-lg border-border border bg-card text-card-foreground",
|
|
9
9
|
{
|
|
10
10
|
variants: {
|
|
@@ -34,45 +34,45 @@ const V = N(
|
|
|
34
34
|
padding: "default"
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
|
-
), g =
|
|
37
|
+
), g = w.forwardRef(
|
|
38
38
|
({
|
|
39
|
-
className:
|
|
40
|
-
variant:
|
|
41
|
-
size:
|
|
39
|
+
className: t,
|
|
40
|
+
variant: n,
|
|
41
|
+
size: r,
|
|
42
42
|
padding: m,
|
|
43
43
|
title: s,
|
|
44
|
-
description:
|
|
45
|
-
toolbar:
|
|
46
|
-
loading:
|
|
47
|
-
emptyMessage:
|
|
48
|
-
error:
|
|
44
|
+
description: l,
|
|
45
|
+
toolbar: a,
|
|
46
|
+
loading: i = !1,
|
|
47
|
+
emptyMessage: c,
|
|
48
|
+
error: d,
|
|
49
49
|
children: h,
|
|
50
|
-
...
|
|
51
|
-
},
|
|
52
|
-
const
|
|
53
|
-
return /* @__PURE__ */
|
|
50
|
+
...f
|
|
51
|
+
}, u) => {
|
|
52
|
+
const x = s || l || a;
|
|
53
|
+
return /* @__PURE__ */ o(
|
|
54
54
|
"div",
|
|
55
55
|
{
|
|
56
|
-
ref:
|
|
57
|
-
className:
|
|
56
|
+
ref: u,
|
|
57
|
+
className: W(
|
|
58
58
|
"flex flex-col",
|
|
59
|
-
V({ variant:
|
|
59
|
+
V({ variant: n, size: r, padding: m, className: t })
|
|
60
60
|
),
|
|
61
|
-
...
|
|
61
|
+
...f,
|
|
62
62
|
children: [
|
|
63
|
-
|
|
64
|
-
(s ||
|
|
63
|
+
x && /* @__PURE__ */ o("div", { className: "mb-4 flex items-start justify-between gap-4 flex-shrink-0", children: [
|
|
64
|
+
(s || l) && /* @__PURE__ */ o("div", { className: "flex-1", children: [
|
|
65
65
|
s && /* @__PURE__ */ e("h3", { className: "text-base sm:text-lg font-semibold leading-none tracking-tight", children: s }),
|
|
66
|
-
|
|
66
|
+
l && /* @__PURE__ */ e("p", { className: "mt-1 text-xs sm:text-sm text-muted-foreground", children: l })
|
|
67
67
|
] }),
|
|
68
|
-
|
|
68
|
+
a && /* @__PURE__ */ e("div", { className: "flex-shrink-0 w-full", children: a })
|
|
69
69
|
] }),
|
|
70
|
-
/* @__PURE__ */
|
|
71
|
-
|
|
70
|
+
/* @__PURE__ */ o("div", { className: "relative flex-1 w-full min-h-0", children: [
|
|
71
|
+
i && /* @__PURE__ */ e("div", { className: "absolute inset-0 z-10 flex items-center justify-center bg-transparent backdrop-blur-sm", children: /* @__PURE__ */ o("div", { className: "flex flex-col items-center gap-2", children: [
|
|
72
72
|
/* @__PURE__ */ e("div", { className: "h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent" }),
|
|
73
73
|
/* @__PURE__ */ e("span", { className: "text-xs sm:text-sm text-muted-foreground", children: "Loading..." })
|
|
74
74
|
] }) }),
|
|
75
|
-
|
|
75
|
+
d && /* @__PURE__ */ e("div", { className: "flex h-full items-center justify-center", children: /* @__PURE__ */ o("div", { className: "flex flex-col items-center gap-2 text-destructive", children: [
|
|
76
76
|
/* @__PURE__ */ e(
|
|
77
77
|
"svg",
|
|
78
78
|
{
|
|
@@ -92,9 +92,9 @@ const V = N(
|
|
|
92
92
|
)
|
|
93
93
|
}
|
|
94
94
|
),
|
|
95
|
-
/* @__PURE__ */ e("span", { className: "text-xs sm:text-sm font-medium", children:
|
|
95
|
+
/* @__PURE__ */ e("span", { className: "text-xs sm:text-sm font-medium", children: d })
|
|
96
96
|
] }) }),
|
|
97
|
-
!
|
|
97
|
+
!d && !h && c && /* @__PURE__ */ e("div", { className: "flex h-full items-center justify-center", children: /* @__PURE__ */ o("div", { className: "flex flex-col items-center gap-2 text-muted-foreground", children: [
|
|
98
98
|
/* @__PURE__ */ e(
|
|
99
99
|
"svg",
|
|
100
100
|
{
|
|
@@ -114,9 +114,9 @@ const V = N(
|
|
|
114
114
|
)
|
|
115
115
|
}
|
|
116
116
|
),
|
|
117
|
-
/* @__PURE__ */ e("span", { className: "text-xs sm:text-sm", children:
|
|
117
|
+
/* @__PURE__ */ e("span", { className: "text-xs sm:text-sm", children: c })
|
|
118
118
|
] }) }),
|
|
119
|
-
!
|
|
119
|
+
!d && h
|
|
120
120
|
] })
|
|
121
121
|
]
|
|
122
122
|
}
|
|
@@ -124,63 +124,64 @@ const V = N(
|
|
|
124
124
|
}
|
|
125
125
|
);
|
|
126
126
|
g.displayName = "GraphView";
|
|
127
|
-
function
|
|
128
|
-
series:
|
|
129
|
-
onUnselectSeries:
|
|
130
|
-
loading:
|
|
127
|
+
function M({
|
|
128
|
+
series: t,
|
|
129
|
+
onUnselectSeries: n,
|
|
130
|
+
loading: r,
|
|
131
131
|
title: m,
|
|
132
132
|
description: s,
|
|
133
|
-
toolbar:
|
|
134
|
-
emptyMessage:
|
|
135
|
-
error:
|
|
136
|
-
containerClassName:
|
|
137
|
-
variant:
|
|
133
|
+
toolbar: l,
|
|
134
|
+
emptyMessage: a = "No data available",
|
|
135
|
+
error: i,
|
|
136
|
+
containerClassName: c,
|
|
137
|
+
variant: d,
|
|
138
138
|
size: h,
|
|
139
|
-
padding:
|
|
140
|
-
...
|
|
139
|
+
padding: f,
|
|
140
|
+
...u
|
|
141
141
|
}) {
|
|
142
|
-
|
|
142
|
+
t.length > 0 && t.some((p) => p.data.length > 0), t.length > 0 && t.some((p) => p.data.length > 0);
|
|
143
|
+
const x = !r && t.length === 0, N = t.length > 0;
|
|
143
144
|
return /* @__PURE__ */ e(
|
|
144
145
|
g,
|
|
145
146
|
{
|
|
146
|
-
className:
|
|
147
|
-
variant:
|
|
147
|
+
className: c,
|
|
148
|
+
variant: d,
|
|
148
149
|
size: h,
|
|
149
|
-
padding:
|
|
150
|
+
padding: f,
|
|
150
151
|
title: m,
|
|
151
152
|
description: s,
|
|
152
|
-
toolbar:
|
|
153
|
-
loading:
|
|
154
|
-
error:
|
|
155
|
-
emptyMessage:
|
|
156
|
-
children:
|
|
157
|
-
|
|
153
|
+
toolbar: l,
|
|
154
|
+
loading: r,
|
|
155
|
+
error: i,
|
|
156
|
+
emptyMessage: x ? a : void 0,
|
|
157
|
+
children: N && !i && /* @__PURE__ */ e(
|
|
158
|
+
R,
|
|
158
159
|
{
|
|
159
|
-
series:
|
|
160
|
-
...
|
|
161
|
-
...
|
|
160
|
+
series: t,
|
|
161
|
+
...n ? { onUnselectSeries: n } : {},
|
|
162
|
+
...u
|
|
162
163
|
}
|
|
163
164
|
)
|
|
164
165
|
}
|
|
165
166
|
);
|
|
166
167
|
}
|
|
167
|
-
function
|
|
168
|
-
const
|
|
169
|
-
return
|
|
170
|
-
const
|
|
171
|
-
if (
|
|
172
|
-
const
|
|
173
|
-
s(
|
|
168
|
+
function A(t = 0) {
|
|
169
|
+
const n = v(null), r = v(null), [m, s] = k(null);
|
|
170
|
+
return j(() => {
|
|
171
|
+
const l = () => {
|
|
172
|
+
if (n.current && r.current) {
|
|
173
|
+
const c = r.current.clientWidth, d = n.current.clientWidth;
|
|
174
|
+
s(c - d - t);
|
|
174
175
|
}
|
|
175
|
-
},
|
|
176
|
-
return
|
|
177
|
-
|
|
176
|
+
}, a = r.current, i = a ? new ResizeObserver(l) : null;
|
|
177
|
+
return a && i?.observe(a), () => {
|
|
178
|
+
a && i?.unobserve(a);
|
|
178
179
|
};
|
|
179
|
-
}, [
|
|
180
|
+
}, [t]), { graphWidth: m, parentRef: r, asideRef: n };
|
|
180
181
|
}
|
|
181
182
|
export {
|
|
182
183
|
g as GraphView,
|
|
183
|
-
|
|
184
|
+
M as GraphViewWithData,
|
|
184
185
|
V as graphViewVariants,
|
|
185
|
-
|
|
186
|
+
A as useGraphAside
|
|
186
187
|
};
|