@gearbox-protocol/permissionless-ui 1.23.1 → 1.24.1
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/complex-input/complex-input.cjs +1 -1
- package/dist/cjs/components/graph/graph.cjs +1 -1
- package/dist/cjs/components/smart-number-input/smart-number-input.cjs +1 -1
- package/dist/cjs/components/trading-view/trading-view.cjs +1 -1
- package/dist/esm/components/complex-input/complex-input.js +14 -13
- package/dist/esm/components/graph/graph.js +125 -117
- package/dist/esm/components/smart-number-input/smart-number-input.js +1 -1
- package/dist/esm/components/trading-view/trading-view.js +33 -31
- package/dist/types/components/complex-input/complex-input.d.ts +1 -0
- package/dist/types/components/graph/graph.d.ts +8 -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 e=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),f=require("../input/input.cjs"),C=require("../with-title/with-title.cjs");require("react");const z=require("../../utils/bn-to-input-view.cjs");require("@gearbox-protocol/sdk");const B=require("../../utils/parse-input-to-bn.cjs"),v=require("../../utils/cn.cjs");require("sonner");require("luxon");require("../../utils/z-index.cjs");require("../accordion/accordion.cjs");require("@gearbox-protocol/static");require("@fortawesome/free-solid-svg-icons");require("../icons/fa-icon.cjs");require("../alert-badge/alert-badge.cjs");require("../alert-dialog/alert-dialog.cjs");require("../alert-modal/alert-modal.cjs");require("../tooltip/simple-tooltip.cjs");require("../tooltip/tooltip.cjs");require("react-intl");require("../arc-loader/arc-loader.cjs");require("../asset-line/asset-line.cjs");require("../buttons/back-button/back-button.cjs");require("../buttons/button/button.cjs");require("../buttons/copy-button/copy-button.cjs");require("../buttons/external-button/external-button.cjs");require("../buttons/filter-button/filter-button.cjs");require("../buttons/navigation-button/navigation-button.cjs");require("../buttons/tab-button/tab-button.cjs");require("../token-icon/token-icon.cjs");require("connectkit");require("wagmi");require("viem/siwe");require("../avatar/avatar.cjs");require("../badge/badge.cjs");require("../base-link/base-link.cjs");require("../navigation-context/navigation-context.cjs");require("../button-checkbox/button-checkbox.cjs");require("../card-grid/card-grid.cjs");require("../cards/card/card.cjs");require("../carousel/carousel.cjs");require("../checkbox/checkbox.cjs");require("../checkbox/checkbox-labeled.cjs");require("../checkbox-item/checkbox-item.cjs");require("../client-adapters/styled-button/styled-button.cjs");require("../client-adapters/styled-dialog-container/styled-dialog-container.cjs");require("../client-adapters/styled-rounded-image/styled-rounded-image.cjs");require("../colored-text/colored-text.cjs");require("../points-icon/points-icon.cjs");require("../skeleton/skeleton.cjs");require("../vertical-indicator/vertical-indicator.cjs");require("../vertical-list/vertical-list.cjs");require("../confirm-menu/confirm-menu.cjs");require("../currency-button/currency-button.cjs");require("../description/description.cjs");require("../detailed-apy/detailed-apy.cjs");require("../detailed-page-title/detailed-page-title.cjs");require("../detailed-page-title/detailed-page-title-copy-button.cjs");require("../detailed-page-title/detailed-page-title-explorer-dropdown.cjs");require("../modal/modal.cjs");require("@radix-ui/react-dialog");require("../dialog/dialog-container.cjs");require("../dialog/dialog-content.cjs");require("../dialog/dialog-description.cjs");require("../dialog/dialog-footer.cjs");require("../dialog/dialog-header.cjs");require("../dialog/dialog-title.cjs");require("../dialog/dialog-modal-container.cjs");require("../dialog/dialog-overlay.cjs");require("viem");require("../label/label.cjs");require("../dropdown-menu/dropdown-menu.cjs");require("../dropdown-menu/dropdown-menu-checkbox-item.cjs");require("../dropdown-menu/dropdown-menu-content.cjs");require("../dropdown-menu/dropdown-menu-item.cjs");require("../dropdown-menu/dropdown-menu-label.cjs");require("../dropdown-menu/dropdown-menu-radio-item.cjs");require("../dropdown-menu/dropdown-menu-separator.cjs");require("../dropdown-menu/dropdown-menu-shortcut.cjs");require("../dropdown-menu/dropdown-menu-sub-content.cjs");require("../dropdown-menu/dropdown-menu-sub-trigger.cjs");require("../edit-input/edit-input.cjs");require("../fadeout-loading/fadeout-loading.cjs");require("../filter/filter-block.cjs");require("../filter/filter-checkbox-item.cjs");require("../filter/filter-chip.cjs");require("../filter/filter-chips.cjs");require("../filter/filter-dropdown-item.cjs");require("../filter/filter-group.cjs");require("../filter/filter-label.cjs");require("../search-line/search-line.cjs");require("../tabs/tabs.cjs");require("../filter/filter-modal-item.cjs");require("../filter/filter-radio-item.cjs");require("../filter/filter-separator.cjs");require("../filter/variants.cjs");require("../graph/formatters.cjs");require("lightweight-charts");require("../graph/graph-view.cjs");require("../help-tip/help-tip.cjs");require("../health-factor/health-factor.cjs");require("../horizontal-indicator/horizontal-indicator.cjs");require("../icon-button/icon-button.cjs");require("../layout/col/col.cjs");require("../layout/container/container.cjs");require("../layout/footer/footer.cjs");require("../layout/grid/grid.cjs");require("../layout/header/header.cjs");require("../layout/layout/layout.cjs");require("../page-title/page-title.cjs");require("../layout/social-icons/social-icons.cjs");require("../link/link.cjs");require("../token-symbol/token-symbol.cjs");require("../../utils/reactochart-compat.cjs");const N=require("../short-string/short-string.cjs");require("../status-elements/status-elements.cjs");require("../text-button/text-button.cjs");require("../loader/loader.cjs");require("../loading/loading.cjs");require("../loading-bar/loading-bar.cjs");require("react-markdown");require("remark-gfm");require("../navbar/navbar.cjs");require("../navbar/navbar-indicator-context.cjs");require("../app-bar/app-bar.cjs");require("../navitem/navitem.cjs");require("../simple-dropdown/simple-dropdown.cjs");require("../progress/progress.cjs");require("../pool-indicator-icon/pool-indicator-icon.cjs");require("../progress-bar/progress-bar.cjs");require("../radio-group/radio-group.cjs");require("../rounded-image/rounded-image.cjs");require("../search-bar/search-bar.cjs");require("../segmented-control/segmented-control.cjs");require("../select/select.cjs");require("../separate-line/separate-line.cjs");require("../separator/separator.cjs");require("../simple-accordion/simple-accordion.cjs");require("../simple-dropdown/simple-dropdown-menu-item.cjs");require("../slider/slider.cjs");require("../slider/slider-context.cjs");require("@radix-ui/react-slider");const V=require("../smart-number-input/balance-indicator.cjs");require("../smart-number-input/smart-number-input.cjs");require("../spinner/spinner.cjs");require("../spinner-loader/spinner-loader.cjs");require("../split-list/split-list.cjs");require("../stat-badge/stat-badge.cjs");require("../status-dot/status-dot.cjs");require("../stepper/stepper.cjs");require("../switch/switch.cjs");require("../table/grid-table.cjs");require("../table/table.cjs");require("../table/grid-table-loader.cjs");require("../textarea/textarea.cjs");require("../theme-provider.cjs");require("../time-to-liquidation/time-to-liquidation.cjs");require("../tip-card/tip-card.cjs");require("../toggle/toggle.cjs");require("../typography/typography.cjs");require("../with-filter-button/with-filter-button.cjs");function k({titleProps:c,inputProps:l,balanceIndicatorProps:a}){const{title:m,className:p,size:d="md",...h}=c,{size:x="sm",title:g="Max",maxButton:I=!0,token:i,maxAmount:u,...T}=a,{decimals:t=18}=i||{},{colorTheme:_="filledLight",onChange:n,maxTokenLength:w=15,...j}=l,S=r=>{const q=r.target.value,[o,s]=B.parseInputToBN(q,t);o===null||s===null||n?.(o,s)},b=()=>{const r=u||0n,q=z.bnToInputView(r,t);n?.(r,q)};return e.jsx(C.WithTitle,{className:v.cn(p),size:d,title:e.jsxs("div",{className:"flex flex-nowrap justify-between items-center",children:[m,u!==void 0&&e.jsx(V.BalanceIndicator,{token:i,title:g,size:x,maxButton:I,maxAmount:u,onMaxButtonClick:b,...T})]}),...h,children:e.jsx(f.Input,{colorTheme:_,onChange:S,endingIcon:e.jsx(N.ShortString,{maxLength:w,children:i?.title}),...j})})}exports.ComplexInput=k;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("react/jsx-runtime"),ve=require("lightweight-charts"),s=require("react"),Se=require("../../hooks/use-media-query.cjs"),fe=require("../../utils/cn.cjs"),E=require("../../utils/colors.cjs"),H=require("./default-config.cjs"),oe=require("./formatters.cjs"),xe=require("./graph-current-value.cjs"),Re=require("./graph-tooltip.cjs"),ye=require("./plugins/vertical-line.cjs");function we(e){const y=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const g in e)if(g!=="default"){const w=Object.getOwnPropertyDescriptor(e,g);Object.defineProperty(y,g,w.get?w:{enumerable:!0,get:()=>e[g]})}}return y.default=e,Object.freeze(y)}const re=we(s),Y=[{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:"#ef4444",top:"rgba(239, 68, 68, 0.56)",bottom:"rgba(239, 68, 68, 0.04)"},{line:"#f59e0b",top:"rgba(245, 158, 11, 0.56)",bottom:"rgba(245, 158, 11, 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:"#06b6d4",top:"rgba(6, 182, 212, 0.56)",bottom:"rgba(6, 182, 212, 0.04)"},{line:"#0ea5e9",top:"rgba(14, 165, 233, 0.56)",bottom:"rgba(14, 165, 233, 0.04)"},{line:"#6366f1",top:"rgba(99, 102, 241, 0.56)",bottom:"rgba(99, 102, 241, 0.04)"},{line:"#d946ef",top:"rgba(217, 70, 239, 0.56)",bottom:"rgba(217, 70, 239, 0.04)"},{line:"#10b981",top:"rgba(16, 185, 129, 0.56)",bottom:"rgba(16, 185, 129, 0.04)"},{line:"#ea580c",top:"rgba(234, 88, 12, 0.56)",bottom:"rgba(234, 88, 12, 0.04)"},{line:"#84cc16",top:"rgba(132, 204, 22, 0.56)",bottom:"rgba(132, 204, 22, 0.04)"},{line:"#0d9488",top:"rgba(13, 148, 136, 0.56)",bottom:"rgba(13, 148, 136, 0.04)"},{line:"#eab308",top:"rgba(234, 179, 8, 0.56)",bottom:"rgba(234, 179, 8, 0.04)"},{line:"#f43f5e",top:"rgba(244, 63, 94, 0.56)",bottom:"rgba(244, 63, 94, 0.04)"},{line:"#d97706",top:"rgba(217, 119, 6, 0.56)",bottom:"rgba(217, 119, 6, 0.04)"},{line:"#64748b",top:"rgba(100, 116, 139, 0.56)",bottom:"rgba(100, 116, 139, 0.04)"},{line:"#475569",top:"rgba(71, 85, 105, 0.56)",bottom:"rgba(71, 85, 105, 0.04)"}],Le=137.5;function ne(e){if(e<Y.length)return Y[e];const g=(e-Y.length)*Le%360,w=E.hslToHex(g,70,50),{topColor:x,bottomColor:O}=E.generateColorsFromBase(w);return{line:w,top:x,bottom:O}}function Pe({series:e,className:y,showLegend:g=!1,onUnselectSeries:w,xMeasureUnit:x="time",yMeasureUnit:O="token",optionsOverrides:q,verticalLineOptions:z,currentValueDecimals:ae}){const L=s.useRef(null),S=s.useRef(new Map),$=s.useRef(!1),X=s.useRef(new Set),le=s.useRef(0),ie=s.useRef(!0),W=s.useRef(null),ge=s.useRef(null),_=s.useRef(null),Z=s.useRef(null),k=Se.useIsMobile(),M=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]=s.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}),[ce,j]=s.useState(null);s.useEffect(()=>{const o=()=>{if(L.current&&_.current){const m=_.current.clientWidth,a=_.current.clientHeight;L.current.resize(m,a),L.current.timeScale().fitContent()}},r=_.current,l=r?new ResizeObserver(o):null;return r&&l?.observe(r),()=>{r&&l?.unobserve(r)}},[]),s.useEffect(()=>{if(!Z.current||$.current)return;const o=H.getDefaultOptions(),r=E.resolveCSSColor("hsl(var(--foreground))","rgb(0, 0, 0)"),l=ve.createChart(Z.current,{...o,rightPriceScale:{...o.rightPriceScale||{},visible:!k,textColor:r},...q});return L.current=l,$.current=!0,()=>{l.remove(),L.current=null,$.current=!1,S.current.clear()}},[k,q]),s.useEffect(()=>{const o=L.current;if(!o||e.length===0)return;const r=x==="time"?oe.getXFormatter(x,M):oe.getXFormatter(x),l=M.map(t=>t.value),{formatter:m,updateVisibleRange:a,updateLastValues:d}=oe.createAdaptiveYAxisFormatter(l);W.current=a,ge.current=d;const C=e.filter(t=>t.data.length>0).map(t=>t.data[t.data.length-1].value);d(C);const R=H.getDefaultOptions();o.applyOptions({localization:{...R.localization||{},timeFormatter:r?(t=>r(parseFloat(t),void 0)):void 0},timeScale:{...R.timeScale||{},tickMarkFormatter:r?(t=>r(parseFloat(t),void 0)):void 0,minBarSpacing:0}});const F=(M.length>0?Math.min(...M.map(t=>t.value)):0)<0,P=M.some(t=>t.value===0),b=!F&&P,i=e.length>1,f=i||k,c=E.resolveCSSColor("hsl(var(--foreground))","rgb(0, 0, 0)");o.applyOptions({rightPriceScale:{...R.rightPriceScale||{},visible:!f,textColor:c,...b&&{scaleMargins:{top:.3,bottom:0}}}});const h=new Set(S.current.keys()),V=new Set(e.map(t=>t.label));for(const t of h)if(!V.has(t)){const n=S.current.get(t);n&&(o.removeSeries(n),S.current.delete(t))}const N=H.getDefaultSeries(),B=[];let I=0;for(let t=0;t<e.length;t++){const n=e[t],ee=ne(t),G=n.color||ee.line;let T,A;if(n.color)if(n.topColor&&n.bottomColor)T=n.topColor,A=n.bottomColor;else if(n.topColor){const u=E.generateColorsFromBase(G);T=n.topColor,A=u.bottomColor}else if(n.bottomColor)T=E.generateColorsFromBase(G).topColor,A=n.bottomColor;else{const u=E.generateColorsFromBase(G);T=u.topColor,A=u.bottomColor}else T=n.topColor||ee.top,A=n.bottomColor||ee.bottom;if(n.data.length===0){const u=S.current.get(n.label);u&&(o.removeSeries(u),S.current.delete(n.label));continue}const he=(n.data.length>0?Math.min(...n.data.map(u=>u.value)):0)<0,pe=n.data.some(u=>u.value===0),Ce=!he&&pe,te=i?I===0?"right":`scale-${I}`:"right";i&&B.push({priceScaleId:te||"right",shouldPreventNegativeAxis:Ce,seriesIndex:I});let D=S.current.get(n.label);D?(D.applyOptions({lineColor:G,topColor:T,bottomColor:A,priceScaleId:te,priceFormat:{type:"custom",formatter:m}}),D.setData(n.data.map(u=>({...u,time:u.time})))):(D=o.addAreaSeries({...N,lineColor:G,topColor:T,bottomColor:A,priceScaleId:te,priceFormat:{type:"custom",formatter:m}}),D.setData(n.data.map(u=>({...u,time:u.time}))),S.current.set(n.label,D)),I++}if(i&&B.length>0)for(const t of B)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(!i)try{const t=o.priceScale("right");t&&t.applyOptions({visible:!k,autoScale:!0,scaleMargins:{top:.1,bottom:.1,...b&&{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)),be=K.size!==X.current.size||[...K].some(t=>!X.current.has(t)),me=M.length!==le.current;(ie.current||be||me||k)&&(o.timeScale().fitContent(),ie.current=!1),X.current=K,le.current=M.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,M,x,O,k]),s.useEffect(()=>{const o=L.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 m=a=>{const{time:d=l,seriesData:C,point:R}=a||{},v=Array.from(S.current.values());if(!R||!d){const b=new Map;for(const i of e)i.data.length>0&&b.set(i.label,i.data[i.data.length-1]);if(Q(b.size>0?b:void 0),r)j(null);else if(v[0]&&l){const f=o.timeScale().timeToCoordinate(l),c=e[0];if(c.data.length>0){const h=c.data[c.data.length-1].value,V=v[0].priceToCoordinate(h);f!==null&&V!==null&&j({x:f,y:V})}}return}const F=new Map;let P;for(let b=0;b<e.length;b++){const i=e[b],f=v[b];if(!f)continue;const c=C?.get(f),h=c&&"value"in c?c.value:void 0,V=i.data[i.data.length-1],N=h!==void 0?h:V?.value??0;b===0&&(P=N),F.set(i.label,{value:N,time:d})}if(Q(F),P!==void 0&&v[0]){const i=o.timeScale().timeToCoordinate(d),f=v[0].priceToCoordinate(P);if(i!==null&&f!==null){const c=_.current;if(c){const h=c.querySelector(".LightweightChart");if(h){const V=h.getBoundingClientRect(),N=c.getBoundingClientRect(),B=i+(V.left-N.left),I=f+(V.top-N.top);j({x:B,y:I})}else j({x:i,y:f})}else j({x:i,y:f})}else j(null)}else j(null)};return o.subscribeCrosshairMove(m),r||requestAnimationFrame(()=>{const a=Array.from(S.current.values());if(a[0]&&l&&e[0]?.data.length>0){const C=o.timeScale().timeToCoordinate(l),R=e[0].data[e[0].data.length-1].value,v=a[0].priceToCoordinate(R);C!==null&&v!==null&&j({x:C,y:v})}}),()=>{o.unsubscribeCrosshairMove(m)}},[e]),s.useEffect(()=>{const o=L.current;if(!o||e.length===0)return;const r=o.timeScale(),l=Math.max(...e.map(a=>a.data.length)),m=()=>{if(l===0)return;const a=r.getVisibleLogicalRange();if(!a)return;const d={from:0,to:l-1},C=typeof a.from=="number"?a.from:0,R=typeof a.to=="number"?a.to:l-1;if(W.current){const b=Math.max(0,Math.floor(C)),i=Math.min(l-1,Math.ceil(R)),f=[];for(const c of e)for(let h=b;h<=i&&h<c.data.length;h++)f.push(c.data[h].value);f.length>0&&W.current(f)}const v=.01;let F=!1;const P={...a};C<d.from-v&&(P.from=d.from,F=!0),R>d.to+v&&(P.to=d.to,F=!0),F&&r.setVisibleLogicalRange(P)};return r.subscribeVisibleLogicalRangeChange(m),()=>{r.unsubscribeVisibleLogicalRangeChange(m)}},[e]),s.useEffect(()=>{const o=L.current,r=Array.from(S.current.values()),l=[];if(o&&r.length>0&&z){const m=H.getDefaultVerticalLine(),a=r[0];for(const d of z){const C=new ye.VertLine(o,a,d.xCoordinate,{...m,...d.options||{}});a.attachPrimitive(C),l.push(C)}}return()=>{if(r.length>0){const m=r[0];for(const a of l)m.detachPrimitive(a)}}},[z]);const J=e.length===1,ue=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 p.jsxs("div",{ref:_,className:fe.cn("relative z-[1] w-full h-full overflow-hidden p-0",y),children:[J&&ue&&p.jsx(xe.GraphCurrentValue,{point:ue,xMeasureUnit:x,yMeasureUnit:O,decimals:ae}),se&&ce&&p.jsx(Re.GraphTooltip,{points:se,xMeasureUnit:x,yMeasureUnit:O,series:e,position:ce,containerRef:_,decimals:ae}),g&&p.jsx(Ve,{series:e,onUnselect:w}),p.jsx("div",{ref:Z,className:"LightweightChart w-full h-full overflow-hidden"})]})}function Ve({series:e,onUnselect:y}){return p.jsx("div",{className:"absolute top-0 left-2 z-[10] flex flex-wrap gap-2",children:e.map((g,w)=>{const x=ne(w),O=g.color||x.line,q=g.data.length===0;return p.jsxs("div",{className:fe.cn("flex items-center gap-1.5 px-2 py-1 bg-background/80 backdrop-blur-sm rounded border border-border",q&&"opacity-50"),children:[p.jsx("div",{className:"w-3 h-3 rounded-sm",style:{backgroundColor:O}}),p.jsxs("span",{className:"text-[10px] sm:text-xs font-medium text-foreground",children:[g.label,q&&" (no data)"]}),y&&p.jsx("button",{type:"button",onClick:z=>{z.stopPropagation(),y(g.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 ${g.label}`,children:p.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:[p.jsx("title",{children:"Close"}),p.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),p.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},g.label)})})}exports.DEFAULT_SERIES_COLORS=Y;exports.Graph=Pe;exports.getSeriesColorPalette=ne;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("react/jsx-runtime"),Se=require("lightweight-charts"),s=require("react"),xe=require("../../hooks/use-media-query.cjs"),ge=require("../../utils/cn.cjs"),E=require("../../utils/colors.cjs"),Y=require("./default-config.cjs"),re=require("./formatters.cjs"),Re=require("./graph-current-value.cjs"),ye=require("./graph-tooltip.cjs"),we=require("./plugins/vertical-line.cjs");function Le(e){const y=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const g in e)if(g!=="default"){const w=Object.getOwnPropertyDescriptor(e,g);Object.defineProperty(y,g,w.get?w:{enumerable:!0,get:()=>e[g]})}}return y.default=e,Object.freeze(y)}const ne=Le(s),$=[{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:"#ef4444",top:"rgba(239, 68, 68, 0.56)",bottom:"rgba(239, 68, 68, 0.04)"},{line:"#f59e0b",top:"rgba(245, 158, 11, 0.56)",bottom:"rgba(245, 158, 11, 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:"#06b6d4",top:"rgba(6, 182, 212, 0.56)",bottom:"rgba(6, 182, 212, 0.04)"},{line:"#0ea5e9",top:"rgba(14, 165, 233, 0.56)",bottom:"rgba(14, 165, 233, 0.04)"},{line:"#6366f1",top:"rgba(99, 102, 241, 0.56)",bottom:"rgba(99, 102, 241, 0.04)"},{line:"#d946ef",top:"rgba(217, 70, 239, 0.56)",bottom:"rgba(217, 70, 239, 0.04)"},{line:"#10b981",top:"rgba(16, 185, 129, 0.56)",bottom:"rgba(16, 185, 129, 0.04)"},{line:"#ea580c",top:"rgba(234, 88, 12, 0.56)",bottom:"rgba(234, 88, 12, 0.04)"},{line:"#84cc16",top:"rgba(132, 204, 22, 0.56)",bottom:"rgba(132, 204, 22, 0.04)"},{line:"#0d9488",top:"rgba(13, 148, 136, 0.56)",bottom:"rgba(13, 148, 136, 0.04)"},{line:"#eab308",top:"rgba(234, 179, 8, 0.56)",bottom:"rgba(234, 179, 8, 0.04)"},{line:"#f43f5e",top:"rgba(244, 63, 94, 0.56)",bottom:"rgba(244, 63, 94, 0.04)"},{line:"#d97706",top:"rgba(217, 119, 6, 0.56)",bottom:"rgba(217, 119, 6, 0.04)"},{line:"#64748b",top:"rgba(100, 116, 139, 0.56)",bottom:"rgba(100, 116, 139, 0.04)"},{line:"#475569",top:"rgba(71, 85, 105, 0.56)",bottom:"rgba(71, 85, 105, 0.04)"}],Ve=137.5;function ae(e){if(e<$.length)return $[e];const g=(e-$.length)*Ve%360,w=E.hslToHex(g,70,50),{topColor:x,bottomColor:O}=E.generateColorsFromBase(w);return{line:w,top:x,bottom:O}}function Pe({series:e,className:y,showLegend:g=!1,onUnselectSeries:w,xMeasureUnit:x="time",yMeasureUnit:O="token",optionsOverrides:q,verticalLineOptions:z,currentValueDecimals:le,useSharedPriceScale:H=!1}){const L=s.useRef(null),S=s.useRef(new Map),X=s.useRef(!1),W=s.useRef(new Set),ie=s.useRef(0),se=s.useRef(!0),Z=s.useRef(null),de=s.useRef(null),_=s.useRef(null),Q=s.useRef(null),k=xe.useIsMobile(),M=ne.useMemo(()=>e.flatMap(o=>o.data),[e]),be=ne.useMemo(()=>{if(e.length>0){const o=e[e.length-1];if(o.data.length>0)return o.data[o.data.length-1]}},[e]),[ce,J]=s.useState(()=>{if(!be)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}),[ue,j]=s.useState(null);s.useEffect(()=>{const o=()=>{if(L.current&&_.current){const m=_.current.clientWidth,a=_.current.clientHeight;L.current.resize(m,a),L.current.timeScale().fitContent()}},r=_.current,l=r?new ResizeObserver(o):null;return r&&l?.observe(r),()=>{r&&l?.unobserve(r)}},[]),s.useEffect(()=>{if(!Q.current||X.current)return;const o=Y.getDefaultOptions(),r=E.resolveCSSColor("hsl(var(--foreground))","rgb(0, 0, 0)"),l=Se.createChart(Q.current,{...o,rightPriceScale:{...o.rightPriceScale||{},visible:!k,textColor:r},...q});return L.current=l,X.current=!0,()=>{l.remove(),L.current=null,X.current=!1,S.current.clear()}},[k,q]),s.useEffect(()=>{const o=L.current;if(!o||e.length===0)return;const r=x==="time"?re.getXFormatter(x,M):re.getXFormatter(x),l=M.map(t=>t.value),{formatter:m,updateVisibleRange:a,updateLastValues:d}=re.createAdaptiveYAxisFormatter(l);Z.current=a,de.current=d;const C=e.filter(t=>t.data.length>0).map(t=>t.data[t.data.length-1].value);d(C);const R=Y.getDefaultOptions();o.applyOptions({localization:{...R.localization||{},timeFormatter:r?(t=>r(parseFloat(t),void 0)):void 0},timeScale:{...R.timeScale||{},tickMarkFormatter:r?(t=>r(parseFloat(t),void 0)):void 0,minBarSpacing:0}});const F=(M.length>0?Math.min(...M.map(t=>t.value)):0)<0,V=M.some(t=>t.value===0),b=!F&&V,i=e.length>1&&!H,f=e.length>1&&!H||k,c=E.resolveCSSColor("hsl(var(--foreground))","rgb(0, 0, 0)");o.applyOptions({rightPriceScale:{...R.rightPriceScale||{},visible:!f,textColor:c,...b&&{scaleMargins:{top:.3,bottom:0}}}});const p=new Set(S.current.keys()),P=new Set(e.map(t=>t.label));for(const t of p)if(!P.has(t)){const n=S.current.get(t);n&&(o.removeSeries(n),S.current.delete(t))}const N=Y.getDefaultSeries(),B=[];let I=0;for(let t=0;t<e.length;t++){const n=e[t],te=ae(t),G=n.color||te.line;let T,A;if(n.color)if(n.topColor&&n.bottomColor)T=n.topColor,A=n.bottomColor;else if(n.topColor){const u=E.generateColorsFromBase(G);T=n.topColor,A=u.bottomColor}else if(n.bottomColor)T=E.generateColorsFromBase(G).topColor,A=n.bottomColor;else{const u=E.generateColorsFromBase(G);T=u.topColor,A=u.bottomColor}else T=n.topColor||te.top,A=n.bottomColor||te.bottom;if(n.data.length===0){const u=S.current.get(n.label);u&&(o.removeSeries(u),S.current.delete(n.label));continue}const he=(n.data.length>0?Math.min(...n.data.map(u=>u.value)):0)<0,Ce=n.data.some(u=>u.value===0),ve=!he&&Ce,oe=H||!i||I===0?"right":`scale-${I}`;i&&B.push({priceScaleId:oe||"right",shouldPreventNegativeAxis:ve,seriesIndex:I});let D=S.current.get(n.label);D?(D.applyOptions({lineColor:G,topColor:T,bottomColor:A,priceScaleId:oe,priceFormat:{type:"custom",formatter:m}}),D.setData(n.data.map(u=>({...u,time:u.time})))):(D=o.addAreaSeries({...N,lineColor:G,topColor:T,bottomColor:A,priceScaleId:oe,priceFormat:{type:"custom",formatter:m}}),D.setData(n.data.map(u=>({...u,time:u.time}))),S.current.set(n.label,D)),I++}if(i&&B.length>0)for(const t of B)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(!i)try{const t=o.priceScale("right");t&&t.applyOptions({visible:!k,autoScale:!0,scaleMargins:{top:.1,bottom:.1,...b&&{top:.3,bottom:0}},alignLabels:!0,borderVisible:!0,borderColor:"rgba(224, 227, 235, 0.1)",entireTextOnly:!1,textColor:c})}catch{}const U=new Set(e.map(t=>t.label)),me=U.size!==W.current.size||[...U].some(t=>!W.current.has(t)),pe=M.length!==ie.current;(se.current||me||pe||k)&&(o.timeScale().fitContent(),se.current=!1),W.current=U,ie.current=M.length;const ee=new Map;for(const t of e)t.data.length>0&&ee.set(t.label,t.data[t.data.length-1]);J(ee.size>0?ee:void 0)},[e,M,x,O,k,H]),s.useEffect(()=>{const o=L.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 m=a=>{const{time:d=l,seriesData:C,point:R}=a||{},v=Array.from(S.current.values());if(!R||!d){const b=new Map;for(const i of e)i.data.length>0&&b.set(i.label,i.data[i.data.length-1]);if(J(b.size>0?b:void 0),r)j(null);else if(v[0]&&l){const f=o.timeScale().timeToCoordinate(l),c=e[0];if(c.data.length>0){const p=c.data[c.data.length-1].value,P=v[0].priceToCoordinate(p);f!==null&&P!==null&&j({x:f,y:P})}}return}const F=new Map;let V;for(let b=0;b<e.length;b++){const i=e[b],f=v[b];if(!f)continue;const c=C?.get(f),p=c&&"value"in c?c.value:void 0,P=i.data[i.data.length-1],N=p!==void 0?p:P?.value??0;b===0&&(V=N),F.set(i.label,{value:N,time:d})}if(J(F),V!==void 0&&v[0]){const i=o.timeScale().timeToCoordinate(d),f=v[0].priceToCoordinate(V);if(i!==null&&f!==null){const c=_.current;if(c){const p=c.querySelector(".LightweightChart");if(p){const P=p.getBoundingClientRect(),N=c.getBoundingClientRect(),B=i+(P.left-N.left),I=f+(P.top-N.top);j({x:B,y:I})}else j({x:i,y:f})}else j({x:i,y:f})}else j(null)}else j(null)};return o.subscribeCrosshairMove(m),r||requestAnimationFrame(()=>{const a=Array.from(S.current.values());if(a[0]&&l&&e[0]?.data.length>0){const C=o.timeScale().timeToCoordinate(l),R=e[0].data[e[0].data.length-1].value,v=a[0].priceToCoordinate(R);C!==null&&v!==null&&j({x:C,y:v})}}),()=>{o.unsubscribeCrosshairMove(m)}},[e]),s.useEffect(()=>{const o=L.current;if(!o||e.length===0)return;const r=o.timeScale(),l=Math.max(...e.map(a=>a.data.length)),m=()=>{if(l===0)return;const a=r.getVisibleLogicalRange();if(!a)return;const d={from:0,to:l-1},C=typeof a.from=="number"?a.from:0,R=typeof a.to=="number"?a.to:l-1;if(Z.current){const b=Math.max(0,Math.floor(C)),i=Math.min(l-1,Math.ceil(R)),f=[];for(const c of e)for(let p=b;p<=i&&p<c.data.length;p++)f.push(c.data[p].value);f.length>0&&Z.current(f)}const v=.01;let F=!1;const V={...a};C<d.from-v&&(V.from=d.from,F=!0),R>d.to+v&&(V.to=d.to,F=!0),F&&r.setVisibleLogicalRange(V)};return r.subscribeVisibleLogicalRangeChange(m),()=>{r.unsubscribeVisibleLogicalRangeChange(m)}},[e]),s.useEffect(()=>{const o=L.current,r=Array.from(S.current.values()),l=[];if(o&&r.length>0&&z){const m=Y.getDefaultVerticalLine(),a=r[0];for(const d of z){const C=new we.VertLine(o,a,d.xCoordinate,{...m,...d.options||{}});a.attachPrimitive(C),l.push(C)}}return()=>{if(r.length>0){const m=r[0];for(const a of l)m.detachPrimitive(a)}}},[z]);const K=e.length===1,fe=ne.useMemo(()=>{if(K&&e.length>0){const o=e[0];if(o.data.length>0)return o.data[o.data.length-1]}},[K,e]);return h.jsxs("div",{ref:_,className:ge.cn("relative z-[1] w-full h-full overflow-hidden p-0",y),children:[K&&fe&&h.jsx(Re.GraphCurrentValue,{point:fe,xMeasureUnit:x,yMeasureUnit:O,decimals:le}),ce&&ue&&h.jsx(ye.GraphTooltip,{points:ce,xMeasureUnit:x,yMeasureUnit:O,series:e,position:ue,containerRef:_,decimals:le}),g&&h.jsx(Me,{series:e,onUnselect:w}),h.jsx("div",{ref:Q,className:"LightweightChart w-full h-full overflow-hidden"})]})}function Me({series:e,onUnselect:y}){return h.jsx("div",{className:"absolute top-0 left-2 z-[10] flex flex-wrap gap-2",children:e.map((g,w)=>{const x=ae(w),O=g.color||x.line,q=g.data.length===0;return h.jsxs("div",{className:ge.cn("flex items-center gap-1.5 px-2 py-1 bg-background/80 backdrop-blur-sm rounded border border-border",q&&"opacity-50"),children:[h.jsx("div",{className:"w-3 h-3 rounded-sm",style:{backgroundColor:O}}),h.jsxs("span",{className:"text-[10px] sm:text-xs font-medium text-foreground",children:[g.label,q&&" (no data)"]}),y&&h.jsx("button",{type:"button",onClick:z=>{z.stopPropagation(),y(g.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 ${g.label}`,children:h.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:[h.jsx("title",{children:"Close"}),h.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),h.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},g.label)})})}exports.DEFAULT_SERIES_COLORS=$;exports.Graph=Pe;exports.getSeriesColorPalette=ae;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),p=require("class-variance-authority"),Q=require("react"),X=require("../currency-button/currency-button.cjs"),$=require("@fortawesome/free-solid-svg-icons"),E=require("../icons/fa-icon.cjs"),d=require("../../hooks/use-media-query.cjs"),G=require("../../utils/bn-to-input-view.cjs");require("@gearbox-protocol/sdk");const H=require("../../utils/parse-input-to-bn.cjs"),m=require("../../utils/cn.cjs");require("sonner");require("luxon");require("../../utils/z-index.cjs");const J=require("./balance-indicator.cjs");function K(s){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const a in s)if(a!=="default"){const r=Object.getOwnPropertyDescriptor(s,a);Object.defineProperty(t,a,r.get?r:{enumerable:!0,get:()=>s[a]})}}return t.default=s,Object.freeze(t)}const v=K(Q),U=p.cva("relative w-full text-foreground bg-gray-20 border border-gray-30 transition-[background-color] duration-100 ease-linear [&:hover]:bg-gray-30 [&:hover]:border-gray-40 data-[active=true]:bg-gray-30 data-[active=true]:outline data-[active=true]:outline-2 data-[active=true]:outline-primary data-[active=true]:outline-offset-[-2px] data-[disabled=true]:cursor-not-allowed",{variants:{size:{sm:"px-3 py-[7px] h-[60px] rounded-[8px]",md:"pl-4 pr-3 py-[10px] h-[82px] rounded-lg"}},defaultVariants:{size:"md"}}),W=p.cva("font-medium text-foreground",{variants:{size:{sm:"text-xs",md:"text-sm"}},defaultVariants:{size:"md"}}),Y=p.cva("w-full p-0 bg-transparent border-none outline-none text-foreground placeholder:text-secondary-foreground focus:outline-none",{variants:{size:{sm:"text-[18px]! leading-[21px]!",md:"text-[28px]! leading-[33px]!"}},defaultVariants:{size:"md"}}),j=v.forwardRef(({amount:s,token:t,label:a="Amount",maxAmount:r,maxAmountLimit:c,maxButtonLabel:w,chainId:I,network:N,maxButton:q=!0,disabled:n=!1,active:z=!1,size:_="md",onSetAmount:o,onShowSelectDialog:f,onRemove:b,onFocus:V,onBlur:B},C)=>{const x=t?.decimals??18,M=u=>{const l=u.target.value,[h,y]=H.parseInputToBN(l,x);h===null||y===null||o&&o(h,y)},k=()=>{if(o){const u=r&&c&&r>c?c:r||0n,l=G.bnToInputView(u,x);o(u,l)}},[S,g]=v.useState(!1),T=()=>{g(!0),V?.()},O=()=>{g(!1),B?.()},i=_??"md",F=d.useIsMobile(),L=d.useIsTablet(),D=d.useIsDesktop(),P=F?20:L?30:D?
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),p=require("class-variance-authority"),Q=require("react"),X=require("../currency-button/currency-button.cjs"),$=require("@fortawesome/free-solid-svg-icons"),E=require("../icons/fa-icon.cjs"),d=require("../../hooks/use-media-query.cjs"),G=require("../../utils/bn-to-input-view.cjs");require("@gearbox-protocol/sdk");const H=require("../../utils/parse-input-to-bn.cjs"),m=require("../../utils/cn.cjs");require("sonner");require("luxon");require("../../utils/z-index.cjs");const J=require("./balance-indicator.cjs");function K(s){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const a in s)if(a!=="default"){const r=Object.getOwnPropertyDescriptor(s,a);Object.defineProperty(t,a,r.get?r:{enumerable:!0,get:()=>s[a]})}}return t.default=s,Object.freeze(t)}const v=K(Q),U=p.cva("relative w-full text-foreground bg-gray-20 border border-gray-30 transition-[background-color] duration-100 ease-linear [&:hover]:bg-gray-30 [&:hover]:border-gray-40 data-[active=true]:bg-gray-30 data-[active=true]:outline data-[active=true]:outline-2 data-[active=true]:outline-primary data-[active=true]:outline-offset-[-2px] data-[disabled=true]:cursor-not-allowed",{variants:{size:{sm:"px-3 py-[7px] h-[60px] rounded-[8px]",md:"pl-4 pr-3 py-[10px] h-[82px] rounded-lg"}},defaultVariants:{size:"md"}}),W=p.cva("font-medium text-foreground",{variants:{size:{sm:"text-xs",md:"text-sm"}},defaultVariants:{size:"md"}}),Y=p.cva("w-full p-0 bg-transparent border-none outline-none text-foreground placeholder:text-secondary-foreground focus:outline-none",{variants:{size:{sm:"text-[18px]! leading-[21px]!",md:"text-[28px]! leading-[33px]!"}},defaultVariants:{size:"md"}}),j=v.forwardRef(({amount:s,token:t,label:a="Amount",maxAmount:r,maxAmountLimit:c,maxButtonLabel:w,chainId:I,network:N,maxButton:q=!0,disabled:n=!1,active:z=!1,size:_="md",onSetAmount:o,onShowSelectDialog:f,onRemove:b,onFocus:V,onBlur:B},C)=>{const x=t?.decimals??18,M=u=>{const l=u.target.value,[h,y]=H.parseInputToBN(l,x);h===null||y===null||o&&o(h,y)},k=()=>{if(o){const u=r&&c&&r>c?c:r||0n,l=G.bnToInputView(u,x);o(u,l)}},[S,g]=v.useState(!1),T=()=>{g(!0),V?.()},O=()=>{g(!1),B?.()},i=_??"md",F=d.useIsMobile(),L=d.useIsTablet(),D=d.useIsDesktop(),P=F?20:L?30:D?22:30,R=!!(t||f);return e.jsxs("div",{ref:C,className:U({size:i}),"data-testid":"smart-number-input-root","data-active":S,"data-disabled":n,children:[b&&e.jsx("div",{className:"absolute top-0 right-0 flex h-5 w-5 translate-x-1/2 -translate-y-1/2 items-center justify-center","data-testid":"smart-number-input-close",children:e.jsx("button",{type:"button",onClick:b,className:"flex h-5 w-5 items-center justify-center rounded-full bg-muted hover:bg-muted/80 text-muted-foreground",children:e.jsx(E.FaIcon,{icon:$.faXmark,className:"size-3"})})}),e.jsxs("div",{className:"mb-2 flex justify-between text-sm leading-[120%]",children:[e.jsx("span",{className:m.cn(W({size:i}),"grow shrink-0 basis-0"),"data-testid":"smart-number-input-label",children:a}),r!==void 0&&t&&e.jsx(J.BalanceIndicator,{title:w,token:t,maxAmount:r,size:i,disabled:n,maxButton:q,onMaxButtonClick:k})]}),e.jsxs("div",{className:m.cn("flex w-full max-w-full shrink-0 basis-full items-center"),children:[e.jsx("div",{className:"mr-3 grow shrink-0 basis-0",children:e.jsx("input",{type:"text",inputMode:"decimal",autoComplete:"off",autoCorrect:"off",spellCheck:"false",pattern:"^[0-9]*[.,]?[0-9]*$",placeholder:"0",value:s,onChange:M,onFocus:T,onBlur:O,disabled:n||!o,className:m.cn(Y({size:i}),n&&"cursor-not-allowed"),"data-testid":"smart-number-input-input",minLength:1,maxLength:79,title:"Amount"})}),R?e.jsx(X.CurrencyButton,{active:z,size:i,disabled:n,token:t,showSelectDialog:f,chainId:I,network:N,maxLength:P,children:t?.symbol??"Select token"}):null]})]})});j.displayName="SmartNumberInput";exports.SmartNumberInput=j;
|
|
@@ -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"),z=require("sonner"),H=require("../../hooks/use-media-query.cjs");require("@gearbox-protocol/sdk");const $=require("../../utils/cn.cjs");require("luxon");require("../../utils/z-index.cjs");const Q=require("../buttons/range-buttons/range-buttons.cjs"),w=require("../graph/graph.cjs"),J=require("../graph/graph-view.cjs"),K=require("./graph-dropdown.cjs"),X=({size:r=16})=>e.jsxs("svg",{width:r,height:r,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"})]}),Y=({size:r=16})=>e.jsxs("svg",{width:r,height:r,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 Z({data:r,yMeasureUnit:n,height:m=306,defaultGraph:x,onGraphSelected:h,graphs:f,isMultipleSelect:S,range:k,rangeList:j,setRange:q,onGraphExpanded:g,isGraphExpanded:D,onUnselectSeries:I,graphsWithNoData:R,loadingGraphs:E,noDataMessage:y="No data available for this graph",currentValueDecimals:L,containerClassName:N,useSharedPriceScale:M,...V}){const l=i.useMemo(()=>Array.isArray(r)?r:r?[r]:[],[r]),A=i.useMemo(()=>Array.isArray(r)&&r.length>1,[r]),_=H.useIsMobile(),B=i.useCallback((a,v)=>{z.toast.error(y)},[y]),T=i.useMemo(()=>{if(n)return Array.isArray(n)?n[0]:n},[n]),O=(!_&&g||j.length>0||h&&f&&x)&&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:h&&f&&x&&e.jsx(K.GraphDropdown,{onSelected:h,items:f,defaultItem:x,multiple:S,graphsWithNoData:R,loadingGraphs:E,onNoDataSelected:B})}),e.jsxs("div",{className:"flex flex-row flex-nowrap justify-start sm:justify-end items-center flex-1",children:[e.jsx(Q.RangeButtons,{range:k,rangeList:j,setRange:q}),!_&&g&&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:g,children:D?e.jsx(Y,{size:16}):e.jsx(X,{size:16})})]})]}),u=i.useRef(new Map),p=i.useRef(0),F=i.useMemo(()=>{const a=Array.isArray(n)?n:void 0;return l.map((v,C)=>{const c=v?.title||`Series ${C+1}`;if(!u.current.has(c)){const t=new Set(Array.from(u.current.values()));let o=p.current;for(let s=0;s<w.DEFAULT_SERIES_COLORS.length;s++){const d=(p.current+s)%w.DEFAULT_SERIES_COLORS.length;if(!t.has(d)){o=d;break}}u.current.set(c,o),p.current=o+1}const W=u.current.get(c)??0,b=w.getSeriesColorPalette(W);return{data:[...v?.data||[]].sort((t,o)=>{const s=typeof t.time=="number"?t.time:Number(t.time),d=typeof o.time=="number"?o.time:Number(o.time);return s-d}).reduce((t,o)=>{const s=o.time;return t.length===0||t[t.length-1].time!==s?t.push({time:s,value:o.value}):t[t.length-1]={time:s,value:o.value},t},[]),label:c,yMeasureUnit:a?.[C]??(Array.isArray(n)?void 0:n),color:b.line,topColor:b.top,bottomColor:b.bottom}})},[l,n]),P=A&&l.length>0?l.some(a=>!a):!r;return e.jsx("div",{style:{width:"100%",height:m?`${m}px`:void 0},className:"w-full",children:e.jsx(J.GraphViewWithData,{series:F,loading:P,toolbar:O,size:m?"full":"default",containerClassName:$.cn("h-full",N),showLegend:A,onUnselectSeries:I,yMeasureUnit:T,currentValueDecimals:L,useSharedPriceScale:M,...V})})}exports.TradingView=Z;
|
|
@@ -5,7 +5,7 @@ import "react";
|
|
|
5
5
|
import { bnToInputView as V } from "../../utils/bn-to-input-view.js";
|
|
6
6
|
import "@gearbox-protocol/sdk";
|
|
7
7
|
import { parseInputToBN as j } from "../../utils/parse-input-to-bn.js";
|
|
8
|
-
import { cn as
|
|
8
|
+
import { cn as L } from "../../utils/cn.js";
|
|
9
9
|
import "sonner";
|
|
10
10
|
import "luxon";
|
|
11
11
|
import "../../utils/z-index.js";
|
|
@@ -160,7 +160,7 @@ import "../tip-card/tip-card.js";
|
|
|
160
160
|
import "../toggle/toggle.js";
|
|
161
161
|
import "../typography/typography.js";
|
|
162
162
|
import "../with-filter-button/with-filter-button.js";
|
|
163
|
-
function
|
|
163
|
+
function yi({
|
|
164
164
|
titleProps: s,
|
|
165
165
|
inputProps: a,
|
|
166
166
|
balanceIndicatorProps: c
|
|
@@ -176,22 +176,23 @@ function Li({
|
|
|
176
176
|
maxButton: I = !0,
|
|
177
177
|
token: i,
|
|
178
178
|
maxAmount: r,
|
|
179
|
-
...
|
|
179
|
+
...T
|
|
180
180
|
} = c, { decimals: p = 18 } = i || {}, {
|
|
181
|
-
colorTheme:
|
|
181
|
+
colorTheme: w = "filledLight",
|
|
182
182
|
onChange: e,
|
|
183
|
+
maxTokenLength: z = 15,
|
|
183
184
|
...C
|
|
184
|
-
} = a,
|
|
185
|
+
} = a, B = (t) => {
|
|
185
186
|
const m = t.target.value, [n, l] = j(m, p);
|
|
186
187
|
n === null || l === null || e?.(n, l);
|
|
187
|
-
},
|
|
188
|
+
}, k = () => {
|
|
188
189
|
const t = r || 0n, m = V(t, p);
|
|
189
190
|
e?.(t, m);
|
|
190
191
|
};
|
|
191
192
|
return /* @__PURE__ */ o(
|
|
192
193
|
S,
|
|
193
194
|
{
|
|
194
|
-
className:
|
|
195
|
+
className: L(d),
|
|
195
196
|
size: f,
|
|
196
197
|
title: /* @__PURE__ */ v("div", { className: "flex flex-nowrap justify-between items-center", children: [
|
|
197
198
|
u,
|
|
@@ -203,8 +204,8 @@ function Li({
|
|
|
203
204
|
size: x,
|
|
204
205
|
maxButton: I,
|
|
205
206
|
maxAmount: r,
|
|
206
|
-
onMaxButtonClick:
|
|
207
|
-
...
|
|
207
|
+
onMaxButtonClick: k,
|
|
208
|
+
...T
|
|
208
209
|
}
|
|
209
210
|
)
|
|
210
211
|
] }),
|
|
@@ -212,9 +213,9 @@ function Li({
|
|
|
212
213
|
children: /* @__PURE__ */ o(
|
|
213
214
|
N,
|
|
214
215
|
{
|
|
215
|
-
colorTheme:
|
|
216
|
-
onChange:
|
|
217
|
-
endingIcon: /* @__PURE__ */ o(M, { maxLength:
|
|
216
|
+
colorTheme: w,
|
|
217
|
+
onChange: B,
|
|
218
|
+
endingIcon: /* @__PURE__ */ o(M, { maxLength: z, children: i?.title }),
|
|
218
219
|
...C
|
|
219
220
|
}
|
|
220
221
|
)
|
|
@@ -222,5 +223,5 @@ function Li({
|
|
|
222
223
|
);
|
|
223
224
|
}
|
|
224
225
|
export {
|
|
225
|
-
|
|
226
|
+
yi as ComplexInput
|
|
226
227
|
};
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { createChart as
|
|
3
|
-
import * as
|
|
4
|
-
import { useRef as x, useState as
|
|
5
|
-
import { useIsMobile as
|
|
6
|
-
import { cn as
|
|
7
|
-
import { hslToHex as
|
|
8
|
-
import { getDefaultOptions as
|
|
9
|
-
import { getXFormatter as dt, createAdaptiveYAxisFormatter as
|
|
10
|
-
import { GraphCurrentValue as
|
|
11
|
-
import { GraphTooltip as
|
|
12
|
-
import { VertLine as
|
|
13
|
-
const
|
|
1
|
+
import { jsxs as $, jsx as y } from "react/jsx-runtime";
|
|
2
|
+
import { createChart as wt } from "lightweight-charts";
|
|
3
|
+
import * as rt from "react";
|
|
4
|
+
import { useRef as x, useState as ft, useEffect as E } from "react";
|
|
5
|
+
import { useIsMobile as Vt } from "../../hooks/use-media-query.js";
|
|
6
|
+
import { cn as bt } from "../../utils/cn.js";
|
|
7
|
+
import { hslToHex as Lt, generateColorsFromBase as q, resolveCSSColor as gt } from "../../utils/colors.js";
|
|
8
|
+
import { getDefaultOptions as mt, getDefaultSeries as Mt, getDefaultVerticalLine as Pt } from "./default-config.js";
|
|
9
|
+
import { getXFormatter as dt, createAdaptiveYAxisFormatter as Nt } from "./formatters.js";
|
|
10
|
+
import { GraphCurrentValue as At } from "./graph-current-value.js";
|
|
11
|
+
import { GraphTooltip as Ft } from "./graph-tooltip.js";
|
|
12
|
+
import { VertLine as Tt } from "./plugins/vertical-line.js";
|
|
13
|
+
const nt = [
|
|
14
14
|
{
|
|
15
15
|
line: "#02c39a",
|
|
16
16
|
top: "rgba(2, 195, 154, 0.56)",
|
|
@@ -106,14 +106,14 @@ const rt = [
|
|
|
106
106
|
top: "rgba(71, 85, 105, 0.56)",
|
|
107
107
|
bottom: "rgba(71, 85, 105, 0.04)"
|
|
108
108
|
}
|
|
109
|
-
],
|
|
110
|
-
function
|
|
111
|
-
if (t <
|
|
112
|
-
return
|
|
113
|
-
const v = (t -
|
|
109
|
+
], It = 137.5;
|
|
110
|
+
function pt(t) {
|
|
111
|
+
if (t < nt.length)
|
|
112
|
+
return nt[t];
|
|
113
|
+
const v = (t - nt.length) * It % 360, k = Lt(v, 70, 50), { topColor: C, bottomColor: N } = q(k);
|
|
114
114
|
return { line: k, top: C, bottom: N };
|
|
115
115
|
}
|
|
116
|
-
function
|
|
116
|
+
function Wt({
|
|
117
117
|
series: t,
|
|
118
118
|
className: G,
|
|
119
119
|
showLegend: v = !1,
|
|
@@ -122,39 +122,40 @@ function qt({
|
|
|
122
122
|
yMeasureUnit: N = "token",
|
|
123
123
|
optionsOverrides: j,
|
|
124
124
|
verticalLineOptions: B,
|
|
125
|
-
currentValueDecimals:
|
|
125
|
+
currentValueDecimals: at,
|
|
126
|
+
useSharedPriceScale: _ = !1
|
|
126
127
|
}) {
|
|
127
|
-
const R = x(null), h = x(/* @__PURE__ */ new Map()),
|
|
128
|
+
const R = x(null), h = x(/* @__PURE__ */ new Map()), W = x(!1), X = x(/* @__PURE__ */ new Set()), lt = x(0), it = x(!0), Z = x(
|
|
128
129
|
null
|
|
129
|
-
),
|
|
130
|
+
), ht = x(null), A = x(null), J = x(null), O = Vt(), L = rt.useMemo(() => t.flatMap((o) => o.data), [t]), vt = rt.useMemo(() => {
|
|
130
131
|
if (t.length > 0) {
|
|
131
132
|
const o = t[t.length - 1];
|
|
132
133
|
if (o.data.length > 0)
|
|
133
134
|
return o.data[o.data.length - 1];
|
|
134
135
|
}
|
|
135
|
-
}, [t]), [
|
|
136
|
-
if (!
|
|
136
|
+
}, [t]), [st, K] = ft(() => {
|
|
137
|
+
if (!vt) return;
|
|
137
138
|
const o = /* @__PURE__ */ new Map();
|
|
138
139
|
for (const r of t)
|
|
139
140
|
r.data.length > 0 && o.set(r.label, r.data[r.data.length - 1]);
|
|
140
141
|
return o;
|
|
141
|
-
}), [
|
|
142
|
+
}), [ct, M] = ft(null);
|
|
142
143
|
E(() => {
|
|
143
144
|
const o = () => {
|
|
144
145
|
if (R.current && A.current) {
|
|
145
|
-
const
|
|
146
|
-
R.current.resize(
|
|
146
|
+
const m = A.current.clientWidth, a = A.current.clientHeight;
|
|
147
|
+
R.current.resize(m, a), R.current.timeScale().fitContent();
|
|
147
148
|
}
|
|
148
149
|
}, r = A.current, l = r ? new ResizeObserver(o) : null;
|
|
149
150
|
return r && l?.observe(r), () => {
|
|
150
151
|
r && l?.unobserve(r);
|
|
151
152
|
};
|
|
152
153
|
}, []), E(() => {
|
|
153
|
-
if (!
|
|
154
|
-
const o =
|
|
154
|
+
if (!J.current || W.current) return;
|
|
155
|
+
const o = mt(), r = gt(
|
|
155
156
|
"hsl(var(--foreground))",
|
|
156
157
|
"rgb(0, 0, 0)"
|
|
157
|
-
), l =
|
|
158
|
+
), l = wt(J.current, {
|
|
158
159
|
...o,
|
|
159
160
|
rightPriceScale: {
|
|
160
161
|
...o.rightPriceScale || {},
|
|
@@ -163,21 +164,21 @@ function qt({
|
|
|
163
164
|
},
|
|
164
165
|
...j
|
|
165
166
|
});
|
|
166
|
-
return R.current = l,
|
|
167
|
-
l.remove(), R.current = null,
|
|
167
|
+
return R.current = l, W.current = !0, () => {
|
|
168
|
+
l.remove(), R.current = null, W.current = !1, h.current.clear();
|
|
168
169
|
};
|
|
169
170
|
}, [O, j]), E(() => {
|
|
170
171
|
const o = R.current;
|
|
171
172
|
if (!o || t.length === 0) return;
|
|
172
173
|
const r = C === "time" ? dt(C, L) : dt(C), l = L.map((e) => e.value), {
|
|
173
|
-
formatter:
|
|
174
|
+
formatter: m,
|
|
174
175
|
updateVisibleRange: a,
|
|
175
176
|
updateLastValues: f
|
|
176
|
-
} =
|
|
177
|
-
|
|
177
|
+
} = Nt(l);
|
|
178
|
+
Z.current = a, ht.current = f;
|
|
178
179
|
const b = t.filter((e) => e.data.length > 0).map((e) => e.data[e.data.length - 1].value);
|
|
179
180
|
f(b);
|
|
180
|
-
const S =
|
|
181
|
+
const S = mt();
|
|
181
182
|
o.applyOptions({
|
|
182
183
|
localization: {
|
|
183
184
|
...S.localization || {},
|
|
@@ -195,7 +196,7 @@ function qt({
|
|
|
195
196
|
minBarSpacing: 0
|
|
196
197
|
}
|
|
197
198
|
});
|
|
198
|
-
const
|
|
199
|
+
const P = (L.length > 0 ? Math.min(...L.map((e) => e.value)) : 0) < 0, w = L.some((e) => e.value === 0), g = !P && w, i = t.length > 1 && !_, u = t.length > 1 && !_ || O, s = gt(
|
|
199
200
|
"hsl(var(--foreground))",
|
|
200
201
|
"rgb(0, 0, 0)"
|
|
201
202
|
);
|
|
@@ -212,40 +213,40 @@ function qt({
|
|
|
212
213
|
}
|
|
213
214
|
}
|
|
214
215
|
});
|
|
215
|
-
const
|
|
216
|
-
for (const e of
|
|
216
|
+
const d = new Set(h.current.keys()), V = new Set(t.map((e) => e.label));
|
|
217
|
+
for (const e of d)
|
|
217
218
|
if (!V.has(e)) {
|
|
218
219
|
const n = h.current.get(e);
|
|
219
220
|
n && (o.removeSeries(n), h.current.delete(e));
|
|
220
221
|
}
|
|
221
|
-
const F =
|
|
222
|
+
const F = Mt(), H = [];
|
|
222
223
|
let z = 0;
|
|
223
224
|
for (let e = 0; e < t.length; e++) {
|
|
224
|
-
const n = t[e],
|
|
225
|
+
const n = t[e], et = pt(e), Y = n.color || et.line;
|
|
225
226
|
let T, I;
|
|
226
227
|
if (n.color)
|
|
227
228
|
if (n.topColor && n.bottomColor)
|
|
228
229
|
T = n.topColor, I = n.bottomColor;
|
|
229
230
|
else if (n.topColor) {
|
|
230
|
-
const c =
|
|
231
|
+
const c = q(Y);
|
|
231
232
|
T = n.topColor, I = c.bottomColor;
|
|
232
233
|
} else if (n.bottomColor)
|
|
233
|
-
T =
|
|
234
|
+
T = q(Y).topColor, I = n.bottomColor;
|
|
234
235
|
else {
|
|
235
|
-
const c =
|
|
236
|
+
const c = q(Y);
|
|
236
237
|
T = c.topColor, I = c.bottomColor;
|
|
237
238
|
}
|
|
238
239
|
else
|
|
239
|
-
T = n.topColor ||
|
|
240
|
+
T = n.topColor || et.top, I = n.bottomColor || et.bottom;
|
|
240
241
|
if (n.data.length === 0) {
|
|
241
242
|
const c = h.current.get(n.label);
|
|
242
243
|
c && (o.removeSeries(c), h.current.delete(n.label));
|
|
243
244
|
continue;
|
|
244
245
|
}
|
|
245
|
-
const
|
|
246
|
+
const xt = (n.data.length > 0 ? Math.min(...n.data.map((c) => c.value)) : 0) < 0, yt = n.data.some((c) => c.value === 0), Rt = !xt && yt, ot = _ || !i || z === 0 ? "right" : `scale-${z}`;
|
|
246
247
|
i && H.push({
|
|
247
|
-
priceScaleId:
|
|
248
|
-
shouldPreventNegativeAxis:
|
|
248
|
+
priceScaleId: ot || "right",
|
|
249
|
+
shouldPreventNegativeAxis: Rt,
|
|
249
250
|
seriesIndex: z
|
|
250
251
|
});
|
|
251
252
|
let D = h.current.get(n.label);
|
|
@@ -253,10 +254,10 @@ function qt({
|
|
|
253
254
|
lineColor: Y,
|
|
254
255
|
topColor: T,
|
|
255
256
|
bottomColor: I,
|
|
256
|
-
priceScaleId:
|
|
257
|
+
priceScaleId: ot,
|
|
257
258
|
priceFormat: {
|
|
258
259
|
type: "custom",
|
|
259
|
-
formatter:
|
|
260
|
+
formatter: m
|
|
260
261
|
}
|
|
261
262
|
}), D.setData(
|
|
262
263
|
n.data.map((c) => ({
|
|
@@ -268,10 +269,10 @@ function qt({
|
|
|
268
269
|
lineColor: Y,
|
|
269
270
|
topColor: T,
|
|
270
271
|
bottomColor: I,
|
|
271
|
-
priceScaleId:
|
|
272
|
+
priceScaleId: ot,
|
|
272
273
|
priceFormat: {
|
|
273
274
|
type: "custom",
|
|
274
|
-
formatter:
|
|
275
|
+
formatter: m
|
|
275
276
|
}
|
|
276
277
|
}), D.setData(
|
|
277
278
|
n.data.map((c) => ({
|
|
@@ -329,13 +330,20 @@ function qt({
|
|
|
329
330
|
});
|
|
330
331
|
} catch {
|
|
331
332
|
}
|
|
332
|
-
const
|
|
333
|
-
(
|
|
334
|
-
const
|
|
333
|
+
const U = new Set(t.map((e) => e.label)), Ct = U.size !== X.current.size || [...U].some((e) => !X.current.has(e)), St = L.length !== lt.current;
|
|
334
|
+
(it.current || Ct || St || O) && (o.timeScale().fitContent(), it.current = !1), X.current = U, lt.current = L.length;
|
|
335
|
+
const tt = /* @__PURE__ */ new Map();
|
|
335
336
|
for (const e of t)
|
|
336
|
-
e.data.length > 0 &&
|
|
337
|
-
|
|
338
|
-
}, [
|
|
337
|
+
e.data.length > 0 && tt.set(e.label, e.data[e.data.length - 1]);
|
|
338
|
+
K(tt.size > 0 ? tt : void 0);
|
|
339
|
+
}, [
|
|
340
|
+
t,
|
|
341
|
+
L,
|
|
342
|
+
C,
|
|
343
|
+
N,
|
|
344
|
+
O,
|
|
345
|
+
_
|
|
346
|
+
]), E(() => {
|
|
339
347
|
const o = R.current;
|
|
340
348
|
if (!o || t.length === 0) return;
|
|
341
349
|
const r = t.length === 1;
|
|
@@ -346,64 +354,64 @@ function qt({
|
|
|
346
354
|
break;
|
|
347
355
|
}
|
|
348
356
|
if (!l) return;
|
|
349
|
-
const
|
|
357
|
+
const m = (a) => {
|
|
350
358
|
const { time: f = l, seriesData: b, point: S } = a || {}, p = Array.from(h.current.values());
|
|
351
359
|
if (!S || !f) {
|
|
352
360
|
const g = /* @__PURE__ */ new Map();
|
|
353
361
|
for (const i of t)
|
|
354
362
|
i.data.length > 0 && g.set(i.label, i.data[i.data.length - 1]);
|
|
355
|
-
if (
|
|
356
|
-
|
|
363
|
+
if (K(g.size > 0 ? g : void 0), r)
|
|
364
|
+
M(null);
|
|
357
365
|
else if (p[0] && l) {
|
|
358
366
|
const u = o.timeScale().timeToCoordinate(l), s = t[0];
|
|
359
367
|
if (s.data.length > 0) {
|
|
360
|
-
const
|
|
361
|
-
u !== null && V !== null &&
|
|
368
|
+
const d = s.data[s.data.length - 1].value, V = p[0].priceToCoordinate(d);
|
|
369
|
+
u !== null && V !== null && M({ x: u, y: V });
|
|
362
370
|
}
|
|
363
371
|
}
|
|
364
372
|
return;
|
|
365
373
|
}
|
|
366
|
-
const
|
|
374
|
+
const P = /* @__PURE__ */ new Map();
|
|
367
375
|
let w;
|
|
368
376
|
for (let g = 0; g < t.length; g++) {
|
|
369
377
|
const i = t[g], u = p[g];
|
|
370
378
|
if (!u) continue;
|
|
371
|
-
const s = b?.get(u),
|
|
372
|
-
g === 0 && (w = F),
|
|
379
|
+
const s = b?.get(u), d = s && "value" in s ? s.value : void 0, V = i.data[i.data.length - 1], F = d !== void 0 ? d : V?.value ?? 0;
|
|
380
|
+
g === 0 && (w = F), P.set(i.label, { value: F, time: f });
|
|
373
381
|
}
|
|
374
|
-
if (
|
|
382
|
+
if (K(P), w !== void 0 && p[0]) {
|
|
375
383
|
const i = o.timeScale().timeToCoordinate(f), u = p[0].priceToCoordinate(w);
|
|
376
384
|
if (i !== null && u !== null) {
|
|
377
385
|
const s = A.current;
|
|
378
386
|
if (s) {
|
|
379
|
-
const
|
|
387
|
+
const d = s.querySelector(
|
|
380
388
|
".LightweightChart"
|
|
381
389
|
);
|
|
382
|
-
if (
|
|
383
|
-
const V =
|
|
384
|
-
|
|
390
|
+
if (d) {
|
|
391
|
+
const V = d.getBoundingClientRect(), F = s.getBoundingClientRect(), H = i + (V.left - F.left), z = u + (V.top - F.top);
|
|
392
|
+
M({ x: H, y: z });
|
|
385
393
|
} else
|
|
386
|
-
|
|
394
|
+
M({ x: i, y: u });
|
|
387
395
|
} else
|
|
388
|
-
|
|
396
|
+
M({ x: i, y: u });
|
|
389
397
|
} else
|
|
390
|
-
|
|
398
|
+
M(null);
|
|
391
399
|
} else
|
|
392
|
-
|
|
400
|
+
M(null);
|
|
393
401
|
};
|
|
394
|
-
return o.subscribeCrosshairMove(
|
|
402
|
+
return o.subscribeCrosshairMove(m), r || requestAnimationFrame(() => {
|
|
395
403
|
const a = Array.from(h.current.values());
|
|
396
404
|
if (a[0] && l && t[0]?.data.length > 0) {
|
|
397
405
|
const b = o.timeScale().timeToCoordinate(l), S = t[0].data[t[0].data.length - 1].value, p = a[0].priceToCoordinate(S);
|
|
398
|
-
b !== null && p !== null &&
|
|
406
|
+
b !== null && p !== null && M({ x: b, y: p });
|
|
399
407
|
}
|
|
400
408
|
}), () => {
|
|
401
|
-
o.unsubscribeCrosshairMove(
|
|
409
|
+
o.unsubscribeCrosshairMove(m);
|
|
402
410
|
};
|
|
403
411
|
}, [t]), E(() => {
|
|
404
412
|
const o = R.current;
|
|
405
413
|
if (!o || t.length === 0) return;
|
|
406
|
-
const r = o.timeScale(), l = Math.max(...t.map((a) => a.data.length)),
|
|
414
|
+
const r = o.timeScale(), l = Math.max(...t.map((a) => a.data.length)), m = () => {
|
|
407
415
|
if (l === 0) return;
|
|
408
416
|
const a = r.getVisibleLogicalRange();
|
|
409
417
|
if (!a) return;
|
|
@@ -411,30 +419,30 @@ function qt({
|
|
|
411
419
|
from: 0,
|
|
412
420
|
to: l - 1
|
|
413
421
|
}, b = typeof a.from == "number" ? a.from : 0, S = typeof a.to == "number" ? a.to : l - 1;
|
|
414
|
-
if (
|
|
422
|
+
if (Z.current) {
|
|
415
423
|
const g = Math.max(0, Math.floor(b)), i = Math.min(l - 1, Math.ceil(S)), u = [];
|
|
416
424
|
for (const s of t)
|
|
417
|
-
for (let
|
|
418
|
-
u.push(s.data[
|
|
419
|
-
u.length > 0 &&
|
|
425
|
+
for (let d = g; d <= i && d < s.data.length; d++)
|
|
426
|
+
u.push(s.data[d].value);
|
|
427
|
+
u.length > 0 && Z.current(u);
|
|
420
428
|
}
|
|
421
429
|
const p = 0.01;
|
|
422
|
-
let
|
|
430
|
+
let P = !1;
|
|
423
431
|
const w = { ...a };
|
|
424
|
-
b < f.from - p && (w.from = f.from,
|
|
432
|
+
b < f.from - p && (w.from = f.from, P = !0), S > f.to + p && (w.to = f.to, P = !0), P && r.setVisibleLogicalRange(w);
|
|
425
433
|
};
|
|
426
|
-
return r.subscribeVisibleLogicalRangeChange(
|
|
434
|
+
return r.subscribeVisibleLogicalRangeChange(m), () => {
|
|
427
435
|
r.unsubscribeVisibleLogicalRangeChange(
|
|
428
|
-
|
|
436
|
+
m
|
|
429
437
|
);
|
|
430
438
|
};
|
|
431
439
|
}, [t]), E(() => {
|
|
432
440
|
const o = R.current, r = Array.from(h.current.values()), l = [];
|
|
433
441
|
if (o && r.length > 0 && B) {
|
|
434
|
-
const
|
|
442
|
+
const m = Pt(), a = r[0];
|
|
435
443
|
for (const f of B) {
|
|
436
|
-
const b = new
|
|
437
|
-
...
|
|
444
|
+
const b = new Tt(o, a, f.xCoordinate, {
|
|
445
|
+
...m,
|
|
438
446
|
...f.options || {}
|
|
439
447
|
});
|
|
440
448
|
a.attachPrimitive(b), l.push(b);
|
|
@@ -442,54 +450,54 @@ function qt({
|
|
|
442
450
|
}
|
|
443
451
|
return () => {
|
|
444
452
|
if (r.length > 0) {
|
|
445
|
-
const
|
|
453
|
+
const m = r[0];
|
|
446
454
|
for (const a of l)
|
|
447
|
-
|
|
455
|
+
m.detachPrimitive(a);
|
|
448
456
|
}
|
|
449
457
|
};
|
|
450
458
|
}, [B]);
|
|
451
|
-
const
|
|
452
|
-
if (
|
|
459
|
+
const Q = t.length === 1, ut = rt.useMemo(() => {
|
|
460
|
+
if (Q && t.length > 0) {
|
|
453
461
|
const o = t[0];
|
|
454
462
|
if (o.data.length > 0)
|
|
455
463
|
return o.data[o.data.length - 1];
|
|
456
464
|
}
|
|
457
|
-
}, [
|
|
458
|
-
return /* @__PURE__ */
|
|
465
|
+
}, [Q, t]);
|
|
466
|
+
return /* @__PURE__ */ $(
|
|
459
467
|
"div",
|
|
460
468
|
{
|
|
461
469
|
ref: A,
|
|
462
|
-
className:
|
|
470
|
+
className: bt(
|
|
463
471
|
"relative z-[1] w-full h-full overflow-hidden p-0",
|
|
464
472
|
G
|
|
465
473
|
),
|
|
466
474
|
children: [
|
|
467
|
-
|
|
468
|
-
|
|
475
|
+
Q && ut && /* @__PURE__ */ y(
|
|
476
|
+
At,
|
|
469
477
|
{
|
|
470
|
-
point:
|
|
478
|
+
point: ut,
|
|
471
479
|
xMeasureUnit: C,
|
|
472
480
|
yMeasureUnit: N,
|
|
473
|
-
decimals:
|
|
481
|
+
decimals: at
|
|
474
482
|
}
|
|
475
483
|
),
|
|
476
|
-
|
|
477
|
-
|
|
484
|
+
st && ct && /* @__PURE__ */ y(
|
|
485
|
+
Ft,
|
|
478
486
|
{
|
|
479
|
-
points:
|
|
487
|
+
points: st,
|
|
480
488
|
xMeasureUnit: C,
|
|
481
489
|
yMeasureUnit: N,
|
|
482
490
|
series: t,
|
|
483
|
-
position:
|
|
491
|
+
position: ct,
|
|
484
492
|
containerRef: A,
|
|
485
|
-
decimals:
|
|
493
|
+
decimals: at
|
|
486
494
|
}
|
|
487
495
|
),
|
|
488
|
-
v && /* @__PURE__ */ y(
|
|
496
|
+
v && /* @__PURE__ */ y(kt, { series: t, onUnselect: k }),
|
|
489
497
|
/* @__PURE__ */ y(
|
|
490
498
|
"div",
|
|
491
499
|
{
|
|
492
|
-
ref:
|
|
500
|
+
ref: J,
|
|
493
501
|
className: "LightweightChart w-full h-full overflow-hidden"
|
|
494
502
|
}
|
|
495
503
|
)
|
|
@@ -497,16 +505,16 @@ function qt({
|
|
|
497
505
|
}
|
|
498
506
|
);
|
|
499
507
|
}
|
|
500
|
-
function
|
|
508
|
+
function kt({
|
|
501
509
|
series: t,
|
|
502
510
|
onUnselect: G
|
|
503
511
|
}) {
|
|
504
512
|
return /* @__PURE__ */ y("div", { className: "absolute top-0 left-2 z-[10] flex flex-wrap gap-2", children: t.map((v, k) => {
|
|
505
|
-
const C =
|
|
506
|
-
return /* @__PURE__ */
|
|
513
|
+
const C = pt(k), N = v.color || C.line, j = v.data.length === 0;
|
|
514
|
+
return /* @__PURE__ */ $(
|
|
507
515
|
"div",
|
|
508
516
|
{
|
|
509
|
-
className:
|
|
517
|
+
className: bt(
|
|
510
518
|
"flex items-center gap-1.5 px-2 py-1 bg-background/80 backdrop-blur-sm rounded border border-border",
|
|
511
519
|
j && "opacity-50"
|
|
512
520
|
),
|
|
@@ -518,7 +526,7 @@ function It({
|
|
|
518
526
|
style: { backgroundColor: N }
|
|
519
527
|
}
|
|
520
528
|
),
|
|
521
|
-
/* @__PURE__ */
|
|
529
|
+
/* @__PURE__ */ $("span", { className: "text-[10px] sm:text-xs font-medium text-foreground", children: [
|
|
522
530
|
v.label,
|
|
523
531
|
j && " (no data)"
|
|
524
532
|
] }),
|
|
@@ -531,7 +539,7 @@ function It({
|
|
|
531
539
|
},
|
|
532
540
|
className: "ml-1 flex items-center justify-center w-4 h-4 rounded-sm hover:bg-muted transition-colors cursor-pointer",
|
|
533
541
|
"aria-label": `Remove ${v.label}`,
|
|
534
|
-
children: /* @__PURE__ */
|
|
542
|
+
children: /* @__PURE__ */ $(
|
|
535
543
|
"svg",
|
|
536
544
|
{
|
|
537
545
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -561,7 +569,7 @@ function It({
|
|
|
561
569
|
}) });
|
|
562
570
|
}
|
|
563
571
|
export {
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
572
|
+
nt as DEFAULT_SERIES_COLORS,
|
|
573
|
+
Wt as Graph,
|
|
574
|
+
pt as getSeriesColorPalette
|
|
567
575
|
};
|
|
@@ -75,7 +75,7 @@ const W = c(
|
|
|
75
75
|
h(!0), B?.();
|
|
76
76
|
}, D = () => {
|
|
77
77
|
h(!1), k?.();
|
|
78
|
-
}, n = I ?? "md", R = J(), S = K(), X = O(), $ = R ? 20 : S ? 30 : X ?
|
|
78
|
+
}, n = I ?? "md", R = J(), S = K(), X = O(), $ = R ? 20 : S ? 30 : X ? 22 : 30, q = !!(t || m);
|
|
79
79
|
return /* @__PURE__ */ u(
|
|
80
80
|
"div",
|
|
81
81
|
{
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { jsxs as d, jsx as t } from "react/jsx-runtime";
|
|
2
|
-
import { useMemo as u, useCallback as
|
|
3
|
-
import { toast as
|
|
4
|
-
import { useIsMobile as
|
|
2
|
+
import { useMemo as u, useCallback as q, useRef as I } from "react";
|
|
3
|
+
import { toast as J } from "sonner";
|
|
4
|
+
import { useIsMobile as K } from "../../hooks/use-media-query.js";
|
|
5
5
|
import "@gearbox-protocol/sdk";
|
|
6
|
-
import { cn as
|
|
6
|
+
import { cn as Q } from "../../utils/cn.js";
|
|
7
7
|
import "luxon";
|
|
8
8
|
import "../../utils/z-index.js";
|
|
9
|
-
import { RangeButtons as
|
|
10
|
-
import { DEFAULT_SERIES_COLORS as N, getSeriesColorPalette as
|
|
11
|
-
import { GraphViewWithData as
|
|
12
|
-
import { GraphDropdown as
|
|
13
|
-
const
|
|
9
|
+
import { RangeButtons as X } from "../buttons/range-buttons/range-buttons.js";
|
|
10
|
+
import { DEFAULT_SERIES_COLORS as N, getSeriesColorPalette as Y } from "../graph/graph.js";
|
|
11
|
+
import { GraphViewWithData as Z } from "../graph/graph-view.js";
|
|
12
|
+
import { GraphDropdown as G } from "./graph-dropdown.js";
|
|
13
|
+
const U = ({ size: e = 16 }) => /* @__PURE__ */ d(
|
|
14
14
|
"svg",
|
|
15
15
|
{
|
|
16
16
|
width: e,
|
|
@@ -27,7 +27,7 @@ const G = ({ size: e = 16 }) => /* @__PURE__ */ d(
|
|
|
27
27
|
/* @__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" })
|
|
28
28
|
]
|
|
29
29
|
}
|
|
30
|
-
),
|
|
30
|
+
), ee = ({ size: e = 16 }) => /* @__PURE__ */ d(
|
|
31
31
|
"svg",
|
|
32
32
|
{
|
|
33
33
|
width: e,
|
|
@@ -45,7 +45,7 @@ const G = ({ size: e = 16 }) => /* @__PURE__ */ d(
|
|
|
45
45
|
]
|
|
46
46
|
}
|
|
47
47
|
);
|
|
48
|
-
function
|
|
48
|
+
function xe({
|
|
49
49
|
data: e,
|
|
50
50
|
yMeasureUnit: n,
|
|
51
51
|
height: f = 306,
|
|
@@ -64,19 +64,20 @@ function pe({
|
|
|
64
64
|
noDataMessage: A = "No data available for this graph",
|
|
65
65
|
currentValueDecimals: M,
|
|
66
66
|
containerClassName: _,
|
|
67
|
-
|
|
67
|
+
useSharedPriceScale: F,
|
|
68
|
+
...T
|
|
68
69
|
}) {
|
|
69
|
-
const l = u(() => Array.isArray(e) ? e : e ? [e] : [], [e]), C = u(() => Array.isArray(e) && e.length > 1, [e]), k =
|
|
70
|
+
const l = u(() => Array.isArray(e) ? e : e ? [e] : [], [e]), C = u(() => Array.isArray(e) && e.length > 1, [e]), k = K(), W = q(
|
|
70
71
|
(a, g) => {
|
|
71
|
-
|
|
72
|
+
J.error(A);
|
|
72
73
|
},
|
|
73
74
|
[A]
|
|
74
|
-
),
|
|
75
|
+
), z = u(() => {
|
|
75
76
|
if (n)
|
|
76
77
|
return Array.isArray(n) ? n[0] : n;
|
|
77
|
-
}, [n]),
|
|
78
|
+
}, [n]), H = (!k && v || y.length > 0 || p && x && h) && /* @__PURE__ */ d("div", { className: "z-10 w-full flex flex-row flex-wrap sm:flex-nowrap items-center gap-2", children: [
|
|
78
79
|
/* @__PURE__ */ t("div", { children: p && x && h && /* @__PURE__ */ t(
|
|
79
|
-
|
|
80
|
+
G,
|
|
80
81
|
{
|
|
81
82
|
onSelected: p,
|
|
82
83
|
items: x,
|
|
@@ -84,22 +85,22 @@ function pe({
|
|
|
84
85
|
multiple: L,
|
|
85
86
|
graphsWithNoData: V,
|
|
86
87
|
loadingGraphs: B,
|
|
87
|
-
onNoDataSelected:
|
|
88
|
+
onNoDataSelected: W
|
|
88
89
|
}
|
|
89
90
|
) }),
|
|
90
91
|
/* @__PURE__ */ d("div", { className: "flex flex-row flex-nowrap justify-start sm:justify-end items-center flex-1", children: [
|
|
91
|
-
/* @__PURE__ */ t(
|
|
92
|
+
/* @__PURE__ */ t(X, { range: S, rangeList: y, setRange: j }),
|
|
92
93
|
!k && v && /* @__PURE__ */ t(
|
|
93
94
|
"button",
|
|
94
95
|
{
|
|
95
96
|
type: "button",
|
|
96
97
|
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",
|
|
97
98
|
onClick: v,
|
|
98
|
-
children: E ? /* @__PURE__ */ t(
|
|
99
|
+
children: E ? /* @__PURE__ */ t(ee, { size: 16 }) : /* @__PURE__ */ t(U, { size: 16 })
|
|
99
100
|
}
|
|
100
101
|
)
|
|
101
102
|
] })
|
|
102
|
-
] }), s = I(/* @__PURE__ */ new Map()), b = I(0),
|
|
103
|
+
] }), s = I(/* @__PURE__ */ new Map()), b = I(0), O = u(() => {
|
|
103
104
|
const a = Array.isArray(n) ? n : void 0;
|
|
104
105
|
return l.map((g, D) => {
|
|
105
106
|
const m = g?.title || `Series ${D + 1}`;
|
|
@@ -117,7 +118,7 @@ function pe({
|
|
|
117
118
|
}
|
|
118
119
|
s.current.set(m, o), b.current = o + 1;
|
|
119
120
|
}
|
|
120
|
-
const
|
|
121
|
+
const $ = s.current.get(m) ?? 0, w = Y($);
|
|
121
122
|
return {
|
|
122
123
|
data: [...g?.data || []].sort((r, o) => {
|
|
123
124
|
const i = typeof r.time == "number" ? r.time : Number(r.time), c = typeof o.time == "number" ? o.time : Number(o.time);
|
|
@@ -139,7 +140,7 @@ function pe({
|
|
|
139
140
|
bottomColor: w.bottom
|
|
140
141
|
};
|
|
141
142
|
});
|
|
142
|
-
}, [l, n]),
|
|
143
|
+
}, [l, n]), P = C && l.length > 0 ? l.some((a) => !a) : !e;
|
|
143
144
|
return /* @__PURE__ */ t(
|
|
144
145
|
"div",
|
|
145
146
|
{
|
|
@@ -149,23 +150,24 @@ function pe({
|
|
|
149
150
|
},
|
|
150
151
|
className: "w-full",
|
|
151
152
|
children: /* @__PURE__ */ t(
|
|
152
|
-
|
|
153
|
+
Z,
|
|
153
154
|
{
|
|
154
|
-
series:
|
|
155
|
-
loading:
|
|
156
|
-
toolbar:
|
|
155
|
+
series: O,
|
|
156
|
+
loading: P,
|
|
157
|
+
toolbar: H,
|
|
157
158
|
size: f ? "full" : "default",
|
|
158
|
-
containerClassName:
|
|
159
|
+
containerClassName: Q("h-full", _),
|
|
159
160
|
showLegend: C,
|
|
160
161
|
onUnselectSeries: R,
|
|
161
|
-
yMeasureUnit:
|
|
162
|
+
yMeasureUnit: z,
|
|
162
163
|
currentValueDecimals: M,
|
|
163
|
-
|
|
164
|
+
useSharedPriceScale: F,
|
|
165
|
+
...T
|
|
164
166
|
}
|
|
165
167
|
)
|
|
166
168
|
}
|
|
167
169
|
);
|
|
168
170
|
}
|
|
169
171
|
export {
|
|
170
|
-
|
|
172
|
+
xe as TradingView
|
|
171
173
|
};
|
|
@@ -55,11 +55,18 @@ export interface GraphProps {
|
|
|
55
55
|
* If 0, rounds to whole numbers. Default is 4.
|
|
56
56
|
*/
|
|
57
57
|
currentValueDecimals?: number;
|
|
58
|
+
/**
|
|
59
|
+
* When true, all series use a single Y axis (shared scale).
|
|
60
|
+
* Use when series are comparable (e.g. "part" vs "whole") so vertical position
|
|
61
|
+
* reflects actual relative values. When false (default), each series has its
|
|
62
|
+
* own scale and fills the chart independently.
|
|
63
|
+
*/
|
|
64
|
+
useSharedPriceScale?: boolean;
|
|
58
65
|
}
|
|
59
66
|
/**
|
|
60
67
|
* Graph component that renders a chart using lightweight-charts library
|
|
61
68
|
* with support for area series, custom tooltips, and vertical line annotations
|
|
62
69
|
* Supports single or multiple series with different colors and legends
|
|
63
70
|
*/
|
|
64
|
-
export declare function Graph({ series, className, showLegend, onUnselectSeries, xMeasureUnit, yMeasureUnit, optionsOverrides, verticalLineOptions, currentValueDecimals, }: GraphProps): React.ReactElement;
|
|
71
|
+
export declare function Graph({ series, className, showLegend, onUnselectSeries, xMeasureUnit, yMeasureUnit, optionsOverrides, verticalLineOptions, currentValueDecimals, useSharedPriceScale, }: GraphProps): React.ReactElement;
|
|
65
72
|
export {};
|
|
@@ -58,6 +58,11 @@ export interface TradingViewProps<T extends string = string> extends Omit<GraphV
|
|
|
58
58
|
* If 0, rounds to whole numbers. Default is 8 (full precision).
|
|
59
59
|
*/
|
|
60
60
|
currentValueDecimals?: number;
|
|
61
|
+
/**
|
|
62
|
+
* When true, all series use a single Y axis so vertical position reflects
|
|
63
|
+
* actual relative values (e.g. "part" vs "whole" like Ethereum vs All Networks).
|
|
64
|
+
*/
|
|
65
|
+
useSharedPriceScale?: boolean;
|
|
61
66
|
}
|
|
62
67
|
/**
|
|
63
68
|
* TradingView — comprehensive charting component with graph selection and time range controls.
|
|
@@ -114,4 +119,4 @@ export interface TradingViewProps<T extends string = string> extends Omit<GraphV
|
|
|
114
119
|
* />
|
|
115
120
|
* ```
|
|
116
121
|
*/
|
|
117
|
-
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, containerClassName, ...restProps }: TradingViewProps<T>): React.ReactElement;
|
|
122
|
+
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, containerClassName, useSharedPriceScale, ...restProps }: TradingViewProps<T>): React.ReactElement;
|