@gearbox-protocol/permissionless-ui 1.17.1 → 1.17.3
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/asset-line/asset-line.cjs +1 -1
- package/dist/cjs/components/graph/graph.cjs +1 -1
- package/dist/cjs/components/options-list/options-list.cjs +1 -1
- package/dist/cjs/components/table/grid-table.cjs +1 -1
- package/dist/cjs/components/table/table.cjs +1 -1
- package/dist/cjs/components/token-icon/token-icon.cjs +1 -1
- package/dist/cjs/components/token-symbol/token-symbol.cjs +1 -1
- package/dist/esm/components/asset-line/asset-line.js +40 -35
- package/dist/esm/components/graph/graph.js +64 -64
- package/dist/esm/components/options-list/options-list.js +15 -16
- package/dist/esm/components/table/grid-table.js +70 -59
- package/dist/esm/components/table/table.js +47 -44
- package/dist/esm/components/token-icon/token-icon.js +2 -2
- package/dist/esm/components/token-symbol/token-symbol.js +9 -9
- package/dist/globals.css +1 -1
- package/dist/types/components/asset-line/asset-line.d.ts +7 -0
- package/dist/types/components/options-list/options-list.d.ts +1 -1
- package/dist/types/components/token-icon/token-icon.d.ts +1 -1
- 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"),R=require("react"),g=require("../description/description.cjs"),h=require("../short-string/short-string.cjs"),l=require("../table/grid-table.cjs"),w=require("../token-symbol/token-symbol.cjs"),p=require("../vspace/vspace.cjs"),L=require("../../utils/cn.cjs");require("sonner");require("@gearbox-protocol/sdk");function A(t){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const r in t)if(r!=="default"){const n=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(s,r,n.get?n:{enumerable:!0,get:()=>t[r]})}}return s.default=t,Object.freeze(s)}const C=A(R),G={default:24,sm:20,md:24,lg:28},x={default:0,sm:2,md:4,lg:4},S=C.forwardRef(({token:t,tokenLabel:s,tokenDescription:r,network:n,chainId:j,value:a,valueDescription:o,size:c="default",iconSize:b=c,gapSize:d=c,last:_,symbolMaxLength:q,descriptionMaxLength:y,onSelect:m,hideValue:u=!1,rounded:N=!0,className:T},O)=>{const i=s||t?.title,f=c==="md"?"default":c;return e.jsxs(l.GridTableRow,{ref:O,className:L.cn(m&&"cursor-pointer",T),onClick:m,cols:u?"1fr":"1fr 1fr",noRound:!N,last:_,children:[e.jsx(l.GridTableCell,{size:f,className:"text-left",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(w.TokenSymbol,{token:t,size:G[b],chainId:j,network:n}),e.jsxs("div",{className:"flex-1 min-w-0",children:[i&&e.jsx(h.ShortString,{maxLength:q,children:i}),i&&r&&e.jsx(p.VSpace,{height:x[d]}),r&&e.jsx(g.Description,{children:e.jsx(h.ShortString,{maxLength:y,showTooltip:!1,children:String(r)})})]})]})}),!u&&e.jsxs(l.GridTableCell,{size:f,className:"text-right",children:[a,a&&o&&e.jsx(p.VSpace,{height:x[d]}),o&&e.jsx(g.Description,{children:o})]})]})});S.displayName="AssetLine";exports.AssetLine=S;
|
|
@@ -1 +1 @@
|
|
|
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"),
|
|
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"),I=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 _=Object.getOwnPropertyDescriptor(e,h);Object.defineProperty(L,h,_.get?_:{enumerable:!0,get:()=>e[h]})}}return L.default=e,Object.freeze(L)}const te=Ce(i),B=[{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:_,xMeasureUnit:P="time",yMeasureUnit:k="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),M=i.useRef(null),W=i.useRef(null),E=he.useIsMobile(),V=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,j]=i.useState(null);i.useEffect(()=>{const t=()=>{if(S.current&&M.current){const u=M.current.clientWidth,a=M.current.clientHeight;S.current.resize(u,a),S.current.timeScale().fitContent()}},n=M.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=I.resolveCSSColor("hsl(var(--foreground))","rgb(0, 0, 0)"),l=me.createChart(W.current,{...t,rightPriceScale:{...t.rightPriceScale||{},visible:!E,textColor:n},...A});return S.current=l,X.current=!0,()=>{l.remove(),S.current=null,X.current=!1,x.current.clear()}},[E,A]),i.useEffect(()=>{const t=S.current;if(!t||e.length===0)return;const n=P==="time"?ee.getXFormatter(P,V):ee.getXFormatter(P),l=ee.getYFormatter(k),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=(V.length>0?Math.min(...V.map(o=>o.value)):0)<0,R=V.some(o=>o.value===0),T=!g&&R,s=e.length>1,F=s||E,y=I.resolveCSSColor("hsl(var(--foreground))","rgb(0, 0, 0)");t.applyOptions({rightPriceScale:{...u.rightPriceScale||{},visible:!E,textColor:y,...T&&{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=B[o%B.length],z=r.color||K.line;let N,O;if(r.color)if(r.topColor&&r.bottomColor)N=r.topColor,O=r.bottomColor;else if(r.topColor){const d=I.generateColorsFromBase(z);N=r.topColor,O=d.bottomColor}else if(r.bottomColor)N=I.generateColorsFromBase(z).topColor,O=r.bottomColor;else{const d=I.generateColorsFromBase(z);N=d.topColor,O=d.bottomColor}else N=r.topColor||K.top,O=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:z,topColor:N,bottomColor:O,priceScaleId:U}),q.setData(r.data)):(q=t.addAreaSeries({...v,lineColor:z,topColor:N,bottomColor:O,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:!F,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(V.length>0){const o=V.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)),G=oe.current,Q=w.size!==G.size||[...w].some(o=>!G.has(o)),H=re.current,ue=p&&H&&(p.from!==H.from||p.to!==H.to);(ne.current||Q||ue||!H||E)&&(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,V,P,k,E]),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:T}=a||{},s=Array.from(x.current.values());if(!T||!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)j(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&&j({x:v,y:p})}}return}const F=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),F.set(c.label,{value:w,time:g})}if(Y(F),y!==void 0&&s[0]){const c=t.timeScale().timeToCoordinate(g),v=s[0].priceToCoordinate(y);if(c!==null&&v!==null){const f=M.current;if(f){const C=f.querySelector(".LightweightChart");if(C){const p=C.getBoundingClientRect(),w=f.getBoundingClientRect(),G=c+(p.left-w.left),Q=v+(p.top-w.top);j({x:G,y:Q})}else j({x:c,y:v})}else j({x:c,y:v})}else j(null)}else j(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),T=e[0].data[e[0].data.length-1].value,s=a[0].priceToCoordinate(T);R!==null&&s!==null&&j({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,T=typeof a.to=="number"?a.to:l-1,s=.01;let F=!1;const y={...a};R<g.from-s&&(y.from=g.from,F=!0),T>g.to+s&&(y.to=g.to,F=!0),F&&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:M,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:k}),ae&&le&&m.jsx(be.GraphTooltip,{points:ae,xMeasureUnit:P,yMeasureUnit:k,series:e,position:le,containerRef:M}),h&&m.jsx(xe,{series:e,onUnselect:_}),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,_)=>{const P=B[_%B.length],k=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:k}}),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=B;exports.Graph=Se;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),m=require("react"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),m=require("react"),f=require("../../utils/cn.cjs");require("sonner");require("@gearbox-protocol/sdk");function b(e){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,s.get?s:{enumerable:!0,get:()=>e[t]})}}return r.default=e,Object.freeze(r)}const i=b(m);function x({className:e,children:r,...t}){const l=i.Children.toArray(r).length,a=i.Children.map(r,(o,c)=>{if(i.isValidElement(o)){const u=c===0,d=c===l-1;return i.cloneElement(o,{first:u,last:d})}return o});return n.jsx("div",{className:f.cn("m-0 p-0 w-full flex flex-wrap",e),...t,children:a})}function p({icon:e,title:r,subTitle:t,onClick:s,endingIcon:l,last:a=!1,className:o}){return n.jsxs("button",{type:"button",onClick:s,className:f.cn("relative z-0 pt-5 px-4 flex flex-row items-start gap-4 w-full cursor-pointer text-left","before:absolute before:-z-10 before:left-0 before:hidden before:w-full before:inset-y-0 before:content-[''] before:bg-muted/50 before:rounded-lg","hover:before:block",!a&&"after:absolute after:bottom-0 after:inset-x-3 after:h-px after:content-[''] after:bg-border",o),children:[e&&n.jsx("div",{className:"w-6 h-6 text-muted-foreground flex items-center justify-center",children:e}),n.jsx("div",{className:"pb-5 flex-1 flex flex-col gap-2",children:n.jsxs("div",{className:"flex flex-col gap-1.5",children:[n.jsx("div",{className:"text-base leading-[1.2] font-medium",children:r}),t&&n.jsx("div",{className:"text-sm text-muted-foreground",children:t})]})}),l&&n.jsx("div",{className:"ml-4 text-muted-foreground transition-colors",children:l})]})}exports.OptionsItem=p;exports.OptionsList=x;
|
|
@@ -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"),n=require("class-variance-authority"),_=require("react"),m=require("../layout/col/col.cjs"),p=require("../layout/grid/grid.cjs"),l=require("../../utils/cn.cjs");function z(e){const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(a,t,r.get?r:{enumerable:!0,get:()=>e[t]})}}return a.default=e,Object.freeze(a)}const d=z(_),T=n.cva("w-full",{variants:{size:{sm:"text-xs",default:"text-sm",lg:"text-base"}},defaultVariants:{size:"default"}}),y=d.forwardRef(({className:e,size:a,cols:t=12,gap:r=0,...i},o)=>s.jsx("div",{className:"relative w-full overflow-auto",children:s.jsx(p.Grid,{ref:o,cols:t,gap:r,className:l.cn(T({size:a,className:e})),...i})}));y.displayName="GridTable";const g=d.forwardRef(({className:e,...a},t)=>s.jsx("div",{ref:t,className:l.cn("contents","[&>*>*]:after:absolute [&>*>*]:after:bottom-0 [&>*>*]:after:inset-x-0 [&>*>*]:after:h-px [&>*>*]:after:bg-border",e),...a}));g.displayName="GridTableHeader";const x=d.forwardRef(({className:e,...a},t)=>s.jsx("div",{ref:t,className:l.cn("contents [&>*:last-child>*]:after:hidden",e),...a}));x.displayName="GridTableBody";const G=d.forwardRef(({className:e,...a},t)=>s.jsx("div",{ref:t,className:l.cn("contents [&>*]:border-t [&>*]:bg-muted/50 [&>*]:font-medium",e),...a}));G.displayName="GridTableFooter";const j=d.forwardRef(({className:e,cols:a,gap:t=0,last:r,height:i,hideValue:o,noHover:w,noRound:b,style:R,...C},V)=>{const u=typeof i=="number"?`${i}px`:i;return s.jsx(p.Grid,{ref:V,cols:a,gap:t,className:l.cn("contents [&>*]:relative [&>*]:transition-colors data-[state=selected]:[&>*]:bg-muted","md:[&>*]:after:absolute md:[&>*]:after:bottom-0 md:[&>*]:after:inset-x-0 md:[&>*]:after:h-px md:[&>*]:after:bg-border",!b&&["md:[&>*:first-child]:after:left-3","md:[&>*:last-child]:after:right-3"],!w&&["[&>*]:z-0","[&>*]:before:absolute [&>*]:before:inset-0 [&>*]:before:-z-10 [&>*]:before:bg-muted/50 [&>*]:before:opacity-0 [&>*]:before:transition-opacity","hover:[&>*]:before:opacity-100",!b&&"[&>*:first-child]:before:rounded-l-lg [&>*:last-child]:before:rounded-r-lg"],r&&"md:[&>*]:after:hidden",o&&"[&>*]:opacity-0",e),style:{...R,...u?{height:u}:{}},...C})});j.displayName="GridTableRow";const h=n.cva("flex items-center justify-startborder-b text-left align-middle font-medium text-muted-foreground !bg-transparent",{variants:{size:{sm:"min-h-8 px-1 py-2 text-xs",default:"min-h-10 px-2 py-2.5",lg:"min-h-12 px-4 py-3"},justify:{start:"justify-start",center:"justify-center",end:"justify-end"}},defaultVariants:{size:"default",justify:"start"}}),c=d.forwardRef(({className:e,size:a,span:t=1,justify:r="start",...i},o)=>s.jsx(m.Col,{ref:o,span:t,className:l.cn(h({size:a,justify:r,className:e})),...i}));c.displayName="GridTableHead";const N=n.cva("align-middle",{variants:{size:{sm:"p-2",default:"p-4",lg:"p-6"},textAlign:{left:"text-left",center:"text-center",right:"text-right"}},defaultVariants:{size:"default"}}),f=d.forwardRef(({className:e,size:a,span:t=1,textAlign:r,...i},o)=>s.jsx(m.Col,{ref:o,span:t,className:l.cn(N({size:a,textAlign:r,className:e})),...i}));f.displayName="GridTableCell";const v=d.forwardRef(({className:e,...a},t)=>s.jsx("div",{ref:t,className:l.cn("col-span-full mt-4 text-sm text-muted-foreground",e),...a}));v.displayName="GridTableCaption";const H=f,q=c;exports.GridTable=y;exports.GridTableBody=x;exports.GridTableCaption=v;exports.GridTableCell=f;exports.GridTableFooter=G;exports.GridTableHead=c;exports.GridTableHeader=g;exports.GridTableRow=j;exports.Td=H;exports.Th=q;exports.gridTableCellVariants=N;exports.gridTableHeadVariants=h;exports.gridTableVariants=T;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),i=require("class-variance-authority"),_=require("lucide-react"),C=require("react"),H=require("../buttons/button/button.cjs"),n=require("../tooltip/tooltip.cjs"),s=require("../../utils/cn.cjs");require("sonner");require("@gearbox-protocol/sdk");function V(e){const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const o=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(a,t,o.get?o:{enumerable:!0,get:()=>e[t]})}}return a.default=e,Object.freeze(a)}const l=V(C),c=i.cva("w-full caption-bottom",{variants:{size:{sm:"text-xs",default:"text-sm",lg:"text-base"}},defaultVariants:{size:"default"}}),b=l.forwardRef(({className:e,size:a,...t},o)=>r.jsx("div",{className:"relative w-full overflow-auto rounded-lg border border-input bg-card",children:r.jsx("table",{ref:o,className:s.cn(c({size:a,className:e})),...t})}));b.displayName="Table";const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),i=require("class-variance-authority"),_=require("lucide-react"),C=require("react"),H=require("../buttons/button/button.cjs"),n=require("../tooltip/tooltip.cjs"),s=require("../../utils/cn.cjs");require("sonner");require("@gearbox-protocol/sdk");function V(e){const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const o=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(a,t,o.get?o:{enumerable:!0,get:()=>e[t]})}}return a.default=e,Object.freeze(a)}const l=V(C),c=i.cva("w-full caption-bottom",{variants:{size:{sm:"text-xs",default:"text-sm",lg:"text-base"}},defaultVariants:{size:"default"}}),b=l.forwardRef(({className:e,size:a,...t},o)=>r.jsx("div",{className:"relative w-full overflow-auto rounded-lg border border-input bg-card",children:r.jsx("table",{ref:o,className:s.cn(c({size:a,className:e})),...t})}));b.displayName="Table";const f=l.forwardRef(({className:e,...a},t)=>r.jsx("thead",{ref:t,className:s.cn("[&_tr]:after:inset-x-0 [&_tr]:after:bg-input [&_tr]:hover:bg-transparent [&_tr]:hover:before:opacity-0",e),...a}));f.displayName="TableHeader";const u=l.forwardRef(({className:e,...a},t)=>r.jsx("tbody",{ref:t,className:s.cn("[&_tr:last-child]:after:hidden",e),...a}));u.displayName="TableBody";const m=l.forwardRef(({className:e,...a},t)=>r.jsx("tfoot",{ref:t,className:s.cn("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",e),...a}));m.displayName="TableFooter";const p=l.forwardRef(({className:e,...a},t)=>r.jsx("tr",{ref:t,className:s.cn("relative transition-colors data-[state=selected]:bg-muted","before:absolute before:inset-0 before:-z-10 before:rounded-lg before:bg-muted/50 before:opacity-0 before:transition-opacity","hover:before:opacity-100","after:absolute after:bottom-0 after:inset-x-3 after:h-px after:bg-border",e),...a}));p.displayName="TableRow";const x=i.cva("border-b bg-muted/50 text-left align-middle font-medium text-muted-foreground border-input",{variants:{size:{sm:"h-8 px-1 text-xs",default:"h-10 px-2",lg:"h-12 px-4"}},defaultVariants:{size:"default"}}),d=l.forwardRef(({className:e,size:a,...t},o)=>r.jsx("th",{ref:o,className:s.cn(x({size:a,className:e})),...t}));d.displayName="TableHead";const g=i.cva("align-middle",{variants:{size:{sm:"p-1",default:"p-2",lg:"p-4"}},defaultVariants:{size:"default"}}),T=l.forwardRef(({className:e,size:a,...t},o)=>r.jsx("td",{ref:o,className:s.cn(g({size:a,className:e})),...t}));T.displayName="TableCell";const y=l.forwardRef(({className:e,...a},t)=>r.jsx("caption",{ref:t,className:s.cn("mt-4 text-sm text-muted-foreground",e),...a}));y.displayName="TableCaption";const h=l.forwardRef(({title:e,isSorted:a,direction:t,setSort:o,placement:j="right",children:v,className:w,...N},R)=>r.jsx(d,{ref:R,className:w,...N,children:r.jsx(n.TooltipProvider,{children:r.jsxs(n.Tooltip,{delayDuration:200,children:[r.jsx(n.TooltipTrigger,{asChild:!0,children:r.jsxs("div",{className:s.cn("group flex items-center gap-1 w-fit cursor-pointer hover:text-foreground",j==="left"?"flex-row-reverse":"flex-row"),onClick:()=>o(t==="asc"?"desc":"asc"),children:[v,r.jsx(H.Button,{variant:"text",size:"auto",className:a?void 0:"opacity-0 group-hover:opacity-100",children:r.jsx(_.ArrowDown,{className:s.cn("h-4 w-4",t==="desc"?"rotate-180":"","transition-transform duration-200 ease-in-out")})})]})}),r.jsxs(n.TooltipContent,{side:"top",children:["Sort by ",e]})]})})}));h.displayName="SortingTableHead";exports.SortingTableHead=h;exports.Table=b;exports.TableBody=u;exports.TableCaption=y;exports.TableCell=T;exports.TableFooter=m;exports.TableHead=d;exports.TableHeader=f;exports.TableRow=p;exports.tableCellVariants=g;exports.tableHeadVariants=x;exports.tableVariants=c;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("react/jsx-runtime"),c=require("react"),p=require("../../utils/cn.cjs"),s="https://static.gearbox.fi/tokens/default.svg",i=new Set;function k(t){const e=t.replace("/","").replace(" ","").replace("-f","").replace("-","_").toLowerCase();if(!e)return s;const n=`https://static.gearbox.fi/tokens/${e}.svg`;return i.has(n)?s:n}function m({symbol:t,size:e=48,className:n}){const o=k(t),[r,l]=c.useState(o),[u,d]=c.useState(!1),a=c.useRef(!1),f=()=>{a.current||(a.current=!0,i.add(r),l(s))},g=()=>{d(!0)};return h.jsx("img",{src:r,alt:"",width:e,height:e,className:p.cn("object-contain
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("react/jsx-runtime"),c=require("react"),p=require("../../utils/cn.cjs"),s="https://static.gearbox.fi/tokens/default.svg",i=new Set;function k(t){const e=t.replace("/","").replace(" ","").replace("-f","").replace("-","_").toLowerCase();if(!e)return s;const n=`https://static.gearbox.fi/tokens/${e}.svg`;return i.has(n)?s:n}function m({symbol:t,size:e=48,className:n}){const o=k(t),[r,l]=c.useState(o),[u,d]=c.useState(!1),a=c.useRef(!1),f=()=>{a.current||(a.current=!0,i.add(r),l(s))},g=()=>{d(!0)};return h.jsx("img",{src:r,alt:"",width:e,height:e,className:p.cn("object-contain",!u&&"bg-gray-200 dark:bg-gray-700 rounded-full",n),style:{width:e,height:e},onError:f,onLoad:g})}function b(t){t.forEach(e=>{const o=`https://static.gearbox.fi/tokens/${e.replace("/","").replace(" ","").replace("-f","").replace("-","_").toLowerCase()}.svg`,r=new window.Image;r.src=o})}exports.TokenIcon=m;exports.preloadTokenIcons=b;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),m=require("../token-icon/token-icon.cjs");require("react");const d=require("../../utils/cn.cjs");require("sonner");require("@gearbox-protocol/sdk");function f(e){if(e)return typeof e=="string"?e:e.symbol}function x(e){if(e)return typeof e=="string"?e:e.title}function g({token:e,title:s,className:c,comment:r,showIcon:o=!0,showSymbol:l=!1,size:u=24,chainId:h,network:p,maxLength:y,...a}){const n=f(e),i=s||x(e);return t.jsxs("div",{className:d.cn("flex items-center gap-3",c),...a,children:[o&&n&&t.jsx(m.TokenIcon,{symbol:n,size:u,className:"shrink-0 self-center"}),l&&i&&t.jsxs("div",{className:"flex items-center gap-1 self-center",children:[t.jsx("div",{className:"text-xs sm:text-sm md:text-base font-medium truncate whitespace-pre-wrap leading-tight",children:i}),r&&t.jsxs("div",{className:"text-md text-muted-foreground leading-tight",children:["(",r,")"]})]})]})}exports.TokenSymbol=g;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { jsxs as t, jsx as r } from "react/jsx-runtime";
|
|
2
2
|
import * as G from "react";
|
|
3
|
-
import { Description as
|
|
3
|
+
import { Description as n } from "../description/description.js";
|
|
4
4
|
import { ShortString as h } from "../short-string/short-string.js";
|
|
5
5
|
import { GridTableRow as I, GridTableCell as p } from "../table/grid-table.js";
|
|
6
|
-
import { TokenSymbol as
|
|
6
|
+
import { TokenSymbol as j } from "../token-symbol/token-symbol.js";
|
|
7
7
|
import { VSpace as g } from "../vspace/vspace.js";
|
|
8
|
-
import { cn as
|
|
8
|
+
import { cn as y } from "../../utils/cn.js";
|
|
9
9
|
import "sonner";
|
|
10
10
|
import "@gearbox-protocol/sdk";
|
|
11
|
-
const
|
|
11
|
+
const E = {
|
|
12
12
|
default: 24,
|
|
13
13
|
sm: 20,
|
|
14
14
|
md: 24,
|
|
@@ -18,66 +18,71 @@ const y = {
|
|
|
18
18
|
sm: 2,
|
|
19
19
|
md: 4,
|
|
20
20
|
lg: 4
|
|
21
|
-
},
|
|
21
|
+
}, Z = G.forwardRef(
|
|
22
22
|
({
|
|
23
|
-
token:
|
|
23
|
+
token: i,
|
|
24
24
|
tokenLabel: S,
|
|
25
|
-
tokenDescription:
|
|
25
|
+
tokenDescription: l,
|
|
26
26
|
network: N,
|
|
27
27
|
chainId: b,
|
|
28
28
|
value: s,
|
|
29
|
-
valueDescription:
|
|
29
|
+
valueDescription: m,
|
|
30
30
|
size: e = "default",
|
|
31
31
|
iconSize: u = e,
|
|
32
|
-
gapSize:
|
|
33
|
-
last:
|
|
34
|
-
symbolMaxLength:
|
|
35
|
-
descriptionMaxLength:
|
|
36
|
-
onSelect:
|
|
37
|
-
hideValue:
|
|
32
|
+
gapSize: a = e,
|
|
33
|
+
last: w,
|
|
34
|
+
symbolMaxLength: L,
|
|
35
|
+
descriptionMaxLength: R,
|
|
36
|
+
onSelect: c,
|
|
37
|
+
hideValue: d = !1,
|
|
38
|
+
rounded: T = !0,
|
|
38
39
|
className: A
|
|
39
40
|
}, C) => {
|
|
40
|
-
const
|
|
41
|
+
const o = S || i?.title, f = e === "md" ? "default" : e;
|
|
41
42
|
return /* @__PURE__ */ t(
|
|
42
43
|
I,
|
|
43
44
|
{
|
|
44
45
|
ref: C,
|
|
45
|
-
className:
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
onClick: d,
|
|
51
|
-
cols: a ? "1fr" : "1fr 1fr",
|
|
52
|
-
noRound: !0,
|
|
46
|
+
className: y(c && "cursor-pointer", A),
|
|
47
|
+
onClick: c,
|
|
48
|
+
cols: d ? "1fr" : "1fr 1fr",
|
|
49
|
+
noRound: !T,
|
|
50
|
+
last: w,
|
|
53
51
|
children: [
|
|
54
|
-
/* @__PURE__ */ r(p, { size:
|
|
52
|
+
/* @__PURE__ */ r(p, { size: f, className: "text-left", children: /* @__PURE__ */ t("div", { className: "flex items-center gap-3", children: [
|
|
55
53
|
/* @__PURE__ */ r(
|
|
56
|
-
|
|
54
|
+
j,
|
|
57
55
|
{
|
|
58
|
-
token:
|
|
59
|
-
size:
|
|
56
|
+
token: i,
|
|
57
|
+
size: E[u],
|
|
60
58
|
chainId: b,
|
|
61
59
|
network: N
|
|
62
60
|
}
|
|
63
61
|
),
|
|
64
62
|
/* @__PURE__ */ t("div", { className: "flex-1 min-w-0", children: [
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
63
|
+
o && /* @__PURE__ */ r(h, { maxLength: L, children: o }),
|
|
64
|
+
o && l && /* @__PURE__ */ r(g, { height: x[a] }),
|
|
65
|
+
l && /* @__PURE__ */ r(n, { children: /* @__PURE__ */ r(
|
|
66
|
+
h,
|
|
67
|
+
{
|
|
68
|
+
maxLength: R,
|
|
69
|
+
showTooltip: !1,
|
|
70
|
+
children: String(l)
|
|
71
|
+
}
|
|
72
|
+
) })
|
|
68
73
|
] })
|
|
69
74
|
] }) }),
|
|
70
|
-
!
|
|
75
|
+
!d && /* @__PURE__ */ t(p, { size: f, className: "text-right", children: [
|
|
71
76
|
s,
|
|
72
|
-
s &&
|
|
73
|
-
|
|
77
|
+
s && m && /* @__PURE__ */ r(g, { height: x[a] }),
|
|
78
|
+
m && /* @__PURE__ */ r(n, { children: m })
|
|
74
79
|
] })
|
|
75
80
|
]
|
|
76
81
|
}
|
|
77
82
|
);
|
|
78
83
|
}
|
|
79
84
|
);
|
|
80
|
-
|
|
85
|
+
Z.displayName = "AssetLine";
|
|
81
86
|
export {
|
|
82
|
-
|
|
87
|
+
Z as AssetLine
|
|
83
88
|
};
|
|
@@ -3,7 +3,7 @@ import { createChart as vt } from "lightweight-charts";
|
|
|
3
3
|
import * as tt from "react";
|
|
4
4
|
import { useRef as V, useState as st, useEffect as D } from "react";
|
|
5
5
|
import { useIsMobile as Ct } from "../../hooks/use-media-query.js";
|
|
6
|
-
import { cn as
|
|
6
|
+
import { cn as dt } from "../../utils/cn.js";
|
|
7
7
|
import { resolveCSSColor as ct, generateColorsFromBase as et } from "../../utils/colors.js";
|
|
8
8
|
import { getDefaultOptions as ut, getDefaultSeries as St, getDefaultVerticalLine as xt } from "./default-config.js";
|
|
9
9
|
import { getXFormatter as ft, getYFormatter as Rt } from "./formatters.js";
|
|
@@ -54,22 +54,22 @@ const q = [
|
|
|
54
54
|
];
|
|
55
55
|
function Bt({
|
|
56
56
|
series: e,
|
|
57
|
-
className:
|
|
57
|
+
className: B,
|
|
58
58
|
showLegend: w = !1,
|
|
59
59
|
onUnselectSeries: W,
|
|
60
60
|
xMeasureUnit: y = "time",
|
|
61
|
-
yMeasureUnit:
|
|
61
|
+
yMeasureUnit: A = "token",
|
|
62
62
|
optionsOverrides: O,
|
|
63
63
|
verticalLineOptions: E
|
|
64
64
|
}) {
|
|
65
|
-
const b = V(null), v = V(/* @__PURE__ */ new Map()), X = V(!1), ot = V(/* @__PURE__ */ new Set()), rt = V(null), nt = V(!0),
|
|
65
|
+
const b = V(null), v = V(/* @__PURE__ */ new Map()), X = V(!1), ot = V(/* @__PURE__ */ new Set()), rt = V(null), nt = V(!0), M = V(null), Y = V(null), z = Ct(), F = tt.useMemo(() => e.flatMap((t) => t.data), [e]), mt = tt.useMemo(() => {
|
|
66
66
|
if (e.length > 0) {
|
|
67
67
|
const t = e[e.length - 1];
|
|
68
68
|
if (t.data.length > 0)
|
|
69
69
|
return t.data[t.data.length - 1];
|
|
70
70
|
}
|
|
71
71
|
}, [e]), [at, Z] = st(() => {
|
|
72
|
-
if (!
|
|
72
|
+
if (!mt) return;
|
|
73
73
|
const t = /* @__PURE__ */ new Map();
|
|
74
74
|
for (const n of e)
|
|
75
75
|
n.data.length > 0 && t.set(n.label, n.data[n.data.length - 1]);
|
|
@@ -77,11 +77,11 @@ function Bt({
|
|
|
77
77
|
}), [lt, L] = st(null);
|
|
78
78
|
D(() => {
|
|
79
79
|
const t = () => {
|
|
80
|
-
if (b.current &&
|
|
81
|
-
const c =
|
|
80
|
+
if (b.current && M.current) {
|
|
81
|
+
const c = M.current.clientWidth, a = M.current.clientHeight;
|
|
82
82
|
b.current.resize(c, a), b.current.timeScale().fitContent();
|
|
83
83
|
}
|
|
84
|
-
}, n =
|
|
84
|
+
}, n = M.current, l = n ? new ResizeObserver(t) : null;
|
|
85
85
|
return n && l?.observe(n), () => {
|
|
86
86
|
n && l?.unobserve(n);
|
|
87
87
|
};
|
|
@@ -94,7 +94,7 @@ function Bt({
|
|
|
94
94
|
...t,
|
|
95
95
|
rightPriceScale: {
|
|
96
96
|
...t.rightPriceScale || {},
|
|
97
|
-
visible: !
|
|
97
|
+
visible: !z,
|
|
98
98
|
textColor: n
|
|
99
99
|
},
|
|
100
100
|
...O
|
|
@@ -102,10 +102,10 @@ function Bt({
|
|
|
102
102
|
return b.current = l, X.current = !0, () => {
|
|
103
103
|
l.remove(), b.current = null, X.current = !1, v.current.clear();
|
|
104
104
|
};
|
|
105
|
-
}, [
|
|
105
|
+
}, [z, O]), D(() => {
|
|
106
106
|
const t = b.current;
|
|
107
107
|
if (!t || e.length === 0) return;
|
|
108
|
-
const n = y === "time" ? ft(y,
|
|
108
|
+
const n = y === "time" ? ft(y, F) : ft(y), l = Rt(A), c = ut();
|
|
109
109
|
t.applyOptions({
|
|
110
110
|
localization: {
|
|
111
111
|
...c.localization || {},
|
|
@@ -123,16 +123,16 @@ function Bt({
|
|
|
123
123
|
minBarSpacing: 0
|
|
124
124
|
}
|
|
125
125
|
});
|
|
126
|
-
const f = (
|
|
126
|
+
const f = (F.length > 0 ? Math.min(...F.map((o) => o.value)) : 0) < 0, C = F.some((o) => o.value === 0), N = !f && C, i = e.length > 1, P = i || z, S = ct(
|
|
127
127
|
"hsl(var(--foreground))",
|
|
128
128
|
"rgb(0, 0, 0)"
|
|
129
129
|
);
|
|
130
130
|
t.applyOptions({
|
|
131
131
|
rightPriceScale: {
|
|
132
132
|
...c.rightPriceScale || {},
|
|
133
|
-
visible: !
|
|
133
|
+
visible: !z,
|
|
134
134
|
textColor: S,
|
|
135
|
-
...
|
|
135
|
+
...N && {
|
|
136
136
|
scaleMargins: {
|
|
137
137
|
top: 0.3,
|
|
138
138
|
bottom: 0
|
|
@@ -149,28 +149,28 @@ function Bt({
|
|
|
149
149
|
const h = St(), u = [];
|
|
150
150
|
let p = 0;
|
|
151
151
|
for (let o = 0; o < e.length; o++) {
|
|
152
|
-
const r = e[o], Q = q[o % q.length],
|
|
153
|
-
let
|
|
152
|
+
const r = e[o], Q = q[o % q.length], j = r.color || Q.line;
|
|
153
|
+
let T, k;
|
|
154
154
|
if (r.color)
|
|
155
155
|
if (r.topColor && r.bottomColor)
|
|
156
|
-
|
|
156
|
+
T = r.topColor, k = r.bottomColor;
|
|
157
157
|
else if (r.topColor) {
|
|
158
|
-
const
|
|
159
|
-
|
|
158
|
+
const d = et(j);
|
|
159
|
+
T = r.topColor, k = d.bottomColor;
|
|
160
160
|
} else if (r.bottomColor)
|
|
161
|
-
|
|
161
|
+
T = et(j).topColor, k = r.bottomColor;
|
|
162
162
|
else {
|
|
163
|
-
const
|
|
164
|
-
|
|
163
|
+
const d = et(j);
|
|
164
|
+
T = d.topColor, k = d.bottomColor;
|
|
165
165
|
}
|
|
166
166
|
else
|
|
167
|
-
|
|
167
|
+
T = r.topColor || Q.top, k = r.bottomColor || Q.bottom;
|
|
168
168
|
if (r.data.length === 0) {
|
|
169
|
-
const
|
|
170
|
-
|
|
169
|
+
const d = v.current.get(r.label);
|
|
170
|
+
d && (t.removeSeries(d), v.current.delete(r.label));
|
|
171
171
|
continue;
|
|
172
172
|
}
|
|
173
|
-
const ht = (r.data.length > 0 ? Math.min(...r.data.map((
|
|
173
|
+
const ht = (r.data.length > 0 ? Math.min(...r.data.map((d) => d.value)) : 0) < 0, pt = r.data.some((d) => d.value === 0), bt = !ht && pt, U = i ? p === 0 ? void 0 : `scale-${p}` : void 0;
|
|
174
174
|
i && u.push({
|
|
175
175
|
priceScaleId: U || "right",
|
|
176
176
|
shouldPreventNegativeAxis: bt,
|
|
@@ -178,19 +178,19 @@ function Bt({
|
|
|
178
178
|
});
|
|
179
179
|
let I = v.current.get(r.label);
|
|
180
180
|
I ? (I.applyOptions({
|
|
181
|
-
lineColor:
|
|
182
|
-
topColor:
|
|
183
|
-
bottomColor:
|
|
181
|
+
lineColor: j,
|
|
182
|
+
topColor: T,
|
|
183
|
+
bottomColor: k,
|
|
184
184
|
priceScaleId: U
|
|
185
185
|
}), I.setData(r.data)) : (I = t.addAreaSeries({
|
|
186
186
|
...h,
|
|
187
|
-
lineColor:
|
|
188
|
-
topColor:
|
|
189
|
-
bottomColor:
|
|
187
|
+
lineColor: j,
|
|
188
|
+
topColor: T,
|
|
189
|
+
bottomColor: k,
|
|
190
190
|
priceScaleId: U,
|
|
191
191
|
priceFormat: {
|
|
192
192
|
type: "custom",
|
|
193
|
-
formatter: (
|
|
193
|
+
formatter: (d) => l(parseFloat(d.toString()), void 0, "short")
|
|
194
194
|
}
|
|
195
195
|
}), I.setData(r.data), v.current.set(r.label, I)), p++;
|
|
196
196
|
}
|
|
@@ -221,25 +221,25 @@ function Bt({
|
|
|
221
221
|
r
|
|
222
222
|
);
|
|
223
223
|
}
|
|
224
|
-
let
|
|
225
|
-
if (
|
|
226
|
-
const o =
|
|
224
|
+
let m = null;
|
|
225
|
+
if (F.length > 0) {
|
|
226
|
+
const o = F.map(
|
|
227
227
|
(r) => typeof r.time == "number" ? r.time : Number(r.time)
|
|
228
228
|
);
|
|
229
|
-
|
|
229
|
+
m = {
|
|
230
230
|
from: Math.min(...o),
|
|
231
231
|
to: Math.max(...o)
|
|
232
232
|
};
|
|
233
233
|
}
|
|
234
|
-
const R = new Set(e.map((o) => o.label)),
|
|
235
|
-
(nt.current || J || gt || !
|
|
234
|
+
const R = new Set(e.map((o) => o.label)), G = ot.current, J = R.size !== G.size || [...R].some((o) => !G.has(o)), H = rt.current, gt = m && H && (m.from !== H.from || m.to !== H.to);
|
|
235
|
+
(nt.current || J || gt || !H || z) && (requestAnimationFrame(() => {
|
|
236
236
|
b.current && b.current.timeScale().fitContent();
|
|
237
|
-
}), nt.current = !1), ot.current = R, rt.current =
|
|
237
|
+
}), nt.current = !1), ot.current = R, rt.current = m;
|
|
238
238
|
const K = /* @__PURE__ */ new Map();
|
|
239
239
|
for (const o of e)
|
|
240
240
|
o.data.length > 0 && K.set(o.label, o.data[o.data.length - 1]);
|
|
241
241
|
Z(K.size > 0 ? K : void 0);
|
|
242
|
-
}, [e,
|
|
242
|
+
}, [e, F, y, A, z]), D(() => {
|
|
243
243
|
const t = b.current;
|
|
244
244
|
if (!t || e.length === 0) return;
|
|
245
245
|
const n = e.length === 1;
|
|
@@ -251,8 +251,8 @@ function Bt({
|
|
|
251
251
|
}
|
|
252
252
|
if (!l) return;
|
|
253
253
|
const c = (a) => {
|
|
254
|
-
const { time: f = l, seriesData: C, point:
|
|
255
|
-
if (!
|
|
254
|
+
const { time: f = l, seriesData: C, point: N } = a || {}, i = Array.from(v.current.values());
|
|
255
|
+
if (!N || !f) {
|
|
256
256
|
const g = /* @__PURE__ */ new Map();
|
|
257
257
|
for (const s of e)
|
|
258
258
|
s.data.length > 0 && g.set(s.label, s.data[s.data.length - 1]);
|
|
@@ -261,8 +261,8 @@ function Bt({
|
|
|
261
261
|
else if (i[0] && l) {
|
|
262
262
|
const h = t.timeScale().timeToCoordinate(l), u = e[0];
|
|
263
263
|
if (u.data.length > 0) {
|
|
264
|
-
const p = u.data[u.data.length - 1].value,
|
|
265
|
-
h !== null &&
|
|
264
|
+
const p = u.data[u.data.length - 1].value, m = i[0].priceToCoordinate(p);
|
|
265
|
+
h !== null && m !== null && L({ x: h, y: m });
|
|
266
266
|
}
|
|
267
267
|
}
|
|
268
268
|
return;
|
|
@@ -272,20 +272,20 @@ function Bt({
|
|
|
272
272
|
for (let g = 0; g < e.length; g++) {
|
|
273
273
|
const s = e[g], h = i[g];
|
|
274
274
|
if (!h) continue;
|
|
275
|
-
const u = C?.get(h), p = u && "value" in u ? u.value : void 0,
|
|
275
|
+
const u = C?.get(h), p = u && "value" in u ? u.value : void 0, m = s.data[s.data.length - 1], R = p !== void 0 ? p : m?.value ?? 0;
|
|
276
276
|
g === 0 && (S = R), P.set(s.label, { value: R, time: f });
|
|
277
277
|
}
|
|
278
278
|
if (Z(P), S !== void 0 && i[0]) {
|
|
279
279
|
const s = t.timeScale().timeToCoordinate(f), h = i[0].priceToCoordinate(S);
|
|
280
280
|
if (s !== null && h !== null) {
|
|
281
|
-
const u =
|
|
281
|
+
const u = M.current;
|
|
282
282
|
if (u) {
|
|
283
283
|
const p = u.querySelector(
|
|
284
284
|
".LightweightChart"
|
|
285
285
|
);
|
|
286
286
|
if (p) {
|
|
287
|
-
const
|
|
288
|
-
L({ x:
|
|
287
|
+
const m = p.getBoundingClientRect(), R = u.getBoundingClientRect(), G = s + (m.left - R.left), J = h + (m.top - R.top);
|
|
288
|
+
L({ x: G, y: J });
|
|
289
289
|
} else
|
|
290
290
|
L({ x: s, y: h });
|
|
291
291
|
} else
|
|
@@ -298,7 +298,7 @@ function Bt({
|
|
|
298
298
|
return t.subscribeCrosshairMove(c), n || requestAnimationFrame(() => {
|
|
299
299
|
const a = Array.from(v.current.values());
|
|
300
300
|
if (a[0] && l && e[0]?.data.length > 0) {
|
|
301
|
-
const C = t.timeScale().timeToCoordinate(l),
|
|
301
|
+
const C = t.timeScale().timeToCoordinate(l), N = e[0].data[e[0].data.length - 1].value, i = a[0].priceToCoordinate(N);
|
|
302
302
|
C !== null && i !== null && L({ x: C, y: i });
|
|
303
303
|
}
|
|
304
304
|
}), () => {
|
|
@@ -314,10 +314,10 @@ function Bt({
|
|
|
314
314
|
const f = {
|
|
315
315
|
from: 0,
|
|
316
316
|
to: l - 1
|
|
317
|
-
}, C = typeof a.from == "number" ? a.from : 0,
|
|
317
|
+
}, C = typeof a.from == "number" ? a.from : 0, N = typeof a.to == "number" ? a.to : l - 1, i = 0.01;
|
|
318
318
|
let P = !1;
|
|
319
319
|
const S = { ...a };
|
|
320
|
-
C < f.from - i && (S.from = f.from, P = !0),
|
|
320
|
+
C < f.from - i && (S.from = f.from, P = !0), N > f.to + i && (S.to = f.to, P = !0), P && n.setVisibleLogicalRange(S);
|
|
321
321
|
};
|
|
322
322
|
return n.subscribeVisibleLogicalRangeChange(c), () => {
|
|
323
323
|
n.unsubscribeVisibleLogicalRangeChange(
|
|
@@ -354,10 +354,10 @@ function Bt({
|
|
|
354
354
|
return /* @__PURE__ */ $(
|
|
355
355
|
"div",
|
|
356
356
|
{
|
|
357
|
-
ref:
|
|
358
|
-
className:
|
|
357
|
+
ref: M,
|
|
358
|
+
className: dt(
|
|
359
359
|
"relative z-[1] w-full h-full overflow-hidden p-0",
|
|
360
|
-
|
|
360
|
+
B
|
|
361
361
|
),
|
|
362
362
|
children: [
|
|
363
363
|
_ && it && /* @__PURE__ */ x(
|
|
@@ -365,7 +365,7 @@ function Bt({
|
|
|
365
365
|
{
|
|
366
366
|
point: it,
|
|
367
367
|
xMeasureUnit: y,
|
|
368
|
-
yMeasureUnit:
|
|
368
|
+
yMeasureUnit: A
|
|
369
369
|
}
|
|
370
370
|
),
|
|
371
371
|
at && lt && /* @__PURE__ */ x(
|
|
@@ -373,10 +373,10 @@ function Bt({
|
|
|
373
373
|
{
|
|
374
374
|
points: at,
|
|
375
375
|
xMeasureUnit: y,
|
|
376
|
-
yMeasureUnit:
|
|
376
|
+
yMeasureUnit: A,
|
|
377
377
|
series: e,
|
|
378
378
|
position: lt,
|
|
379
|
-
containerRef:
|
|
379
|
+
containerRef: M
|
|
380
380
|
}
|
|
381
381
|
),
|
|
382
382
|
w && /* @__PURE__ */ x(Pt, { series: e, onUnselect: W }),
|
|
@@ -393,14 +393,14 @@ function Bt({
|
|
|
393
393
|
}
|
|
394
394
|
function Pt({
|
|
395
395
|
series: e,
|
|
396
|
-
onUnselect:
|
|
396
|
+
onUnselect: B
|
|
397
397
|
}) {
|
|
398
398
|
return /* @__PURE__ */ x("div", { className: "absolute top-0 left-2 z-[10] flex flex-wrap gap-2", children: e.map((w, W) => {
|
|
399
|
-
const y = q[W % q.length],
|
|
399
|
+
const y = q[W % q.length], A = w.color || y.line, O = w.data.length === 0;
|
|
400
400
|
return /* @__PURE__ */ $(
|
|
401
401
|
"div",
|
|
402
402
|
{
|
|
403
|
-
className:
|
|
403
|
+
className: dt(
|
|
404
404
|
"flex items-center gap-1.5 px-2 py-1 bg-background/80 backdrop-blur-sm rounded border border-border",
|
|
405
405
|
O && "opacity-50"
|
|
406
406
|
),
|
|
@@ -409,19 +409,19 @@ function Pt({
|
|
|
409
409
|
"div",
|
|
410
410
|
{
|
|
411
411
|
className: "w-3 h-3 rounded-sm",
|
|
412
|
-
style: { backgroundColor:
|
|
412
|
+
style: { backgroundColor: A }
|
|
413
413
|
}
|
|
414
414
|
),
|
|
415
415
|
/* @__PURE__ */ $("span", { className: "text-[10px] sm:text-xs font-medium text-foreground", children: [
|
|
416
416
|
w.label,
|
|
417
417
|
O && " (no data)"
|
|
418
418
|
] }),
|
|
419
|
-
|
|
419
|
+
B && /* @__PURE__ */ x(
|
|
420
420
|
"button",
|
|
421
421
|
{
|
|
422
422
|
type: "button",
|
|
423
423
|
onClick: (E) => {
|
|
424
|
-
E.stopPropagation(),
|
|
424
|
+
E.stopPropagation(), B(w.label);
|
|
425
425
|
},
|
|
426
426
|
className: "ml-1 flex items-center justify-center w-4 h-4 rounded-sm hover:bg-muted transition-colors cursor-pointer",
|
|
427
427
|
"aria-label": `Remove ${w.label}`,
|