@gearbox-protocol/ui-kit 3.14.0-next.1 → 3.14.0-next.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/smart-number-input/smart-number-input.cjs +1 -1
- package/dist/cjs/components/trading-view/trading-view.cjs +1 -1
- package/dist/esm/components/smart-number-input/smart-number-input.js +127 -100
- package/dist/esm/components/trading-view/trading-view.js +58 -58
- package/dist/globals.css +1 -1
- package/dist/types/components/smart-number-input/smart-number-input.d.ts +12 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),y=require("class-variance-authority"),U=require("react"),W=require("../currency-button/currency-button.cjs"),Y=require("@fortawesome/free-solid-svg-icons"),Z=require("../icons/fa-icon.cjs"),b=require("../../hooks/use-media-query.cjs"),f=require("../../test-ids/smart-number-input.cjs"),A=require("../../utils/bn-to-input-view.cjs");require("@gearbox-protocol/sdk");const ee=require("../../utils/parse-input-to-bn.cjs"),v=require("../../utils/cn.cjs");require("sonner");require("@gearbox-protocol/sdk/common-utils");require("luxon");require("../../utils/z-index.cjs");const te=require("./balance-indicator.cjs");function se(r){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const o in r)if(o!=="default"){const n=Object.getOwnPropertyDescriptor(r,o);Object.defineProperty(s,o,n.get?n:{enumerable:!0,get:()=>r[o]})}}return s.default=r,Object.freeze(s)}const c=se(U),ne=y.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"}}),re=y.cva("font-medium text-foreground",{variants:{size:{sm:"text-xs",md:"text-sm"}},defaultVariants:{size:"md"}}),ae=y.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"}}),k=c.forwardRef(({amount:r,token:s,label:o="Amount",maxAmount:n,maxAmountLimit:p,maxButtonLabel:M,chainId:_,network:C,maxButton:T=!0,disabled:i=!1,active:B=!1,size:V="md",symbolMaxLength:S,tokenOptions:x,onSetAmount:l,onShowSelectDialog:I,onRemove:N,onFocus:L,onBlur:O},F)=>{const j=s?.decimals??18,R=t=>{const a=t.target.value,[q,z]=ee.parseInputToBN(a,j);q===null||z===null||l&&l(q,z)},D=()=>{if(l){const t=n&&p&&n>p?p:n||0n,a=A.bnToInputView(t,j);l(t,a)}},[E,w]=c.useState(!1),P=()=>{w(!0),L?.()},Q=()=>{w(!1),O?.()},u=V??"md",X=b.useIsMobile(),$=b.useIsTablet(),G=b.useIsDesktop(),H=S??(X?20:$?30:G?22:30),[d,g]=c.useState(!1),h=c.useRef(null);c.useEffect(()=>{if(!d)return;const t=a=>{h.current&&!h.current.contains(a.target)&&g(!1)};return document.addEventListener("mousedown",t),()=>document.removeEventListener("mousedown",t)},[d]);const m=!!(x&&x.length>0),J=!i&&m?()=>g(t=>!t):I,K=!!(s||I||m);return e.jsxs("div",{ref:F,className:ne({size:u}),"data-testid":f.smartNumberInputTestIds.root,"data-active":E,"data-disabled":i,children:[N&&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":f.smartNumberInputTestIds.close,children:e.jsx("button",{type:"button",onClick:N,className:"flex h-5 w-5 items-center justify-center rounded-full bg-muted hover:bg-muted/80 text-muted-foreground",children:e.jsx(Z.FaIcon,{icon:Y.faXmark,className:"size-3"})})}),e.jsxs("div",{className:"mb-2 flex justify-between text-sm leading-[120%]",children:[e.jsx("span",{className:v.cn(re({size:u}),"grow shrink-0 basis-0"),"data-testid":f.smartNumberInputTestIds.label,children:o}),n!==void 0&&s&&e.jsx(te.BalanceIndicator,{title:M,token:s,maxAmount:n,size:u,disabled:i,maxButton:T,onMaxButtonClick:D})]}),e.jsxs("div",{className:v.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:r,onChange:R,onFocus:P,onBlur:Q,disabled:i||!l,className:v.cn(ae({size:u}),i&&"cursor-not-allowed"),"data-testid":f.smartNumberInputTestIds.input,minLength:1,maxLength:79,title:"Amount"})}),K?e.jsxs("div",{ref:h,className:"relative shrink-0",children:[e.jsx(W.CurrencyButton,{active:m?d:B,size:u,disabled:i,token:s,showSelectDialog:J,chainId:_,network:C,maxLength:H,children:s?.symbol??"Select token"}),m&&d&&e.jsx("div",{className:"absolute right-0 top-full z-20 mt-1 min-w-[140px] overflow-hidden rounded-lg border border-gray-30 bg-gray-20 shadow-lg",children:x?.map((t,a)=>e.jsxs("button",{type:"button",onClick:()=>{t.onSelect(),g(!1)},className:"flex w-full items-center gap-2 px-3 py-2 text-sm text-foreground hover:bg-gray-30 text-left",children:[t.icon?e.jsx("span",{className:"inline-flex shrink-0 items-center",children:t.icon}):null,e.jsx("span",{className:"truncate",children:t.label})]},a))})]}):null]})]})});k.displayName="SmartNumberInput";exports.SmartNumberInput=k;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),x=require("react"),re=require("sonner"),ne=require("../../hooks/use-media-query.cjs");require("@gearbox-protocol/sdk");const oe=require("../../utils/cn.cjs");require("@gearbox-protocol/sdk/common-utils");require("luxon");require("../../utils/z-index.cjs");const ie=require("../buttons/range-buttons/range-buttons.cjs"),j=require("../graph/graph.cjs"),se=require("../graph/graph-view.cjs"),le=require("./graph-dropdown.cjs"),ce=({size:e=16})=>o.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-label":"Expand fullscreen",children:[o.jsx("title",{children:"Expand fullscreen"}),o.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"})]}),ue=({size:e=16})=>o.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-label":"Exit fullscreen",children:[o.jsx("title",{children:"Exit fullscreen"}),o.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"})]}),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),x=require("react"),re=require("sonner"),ne=require("../../hooks/use-media-query.cjs");require("@gearbox-protocol/sdk");const oe=require("../../utils/cn.cjs");require("@gearbox-protocol/sdk/common-utils");require("luxon");require("../../utils/z-index.cjs");const ie=require("../buttons/range-buttons/range-buttons.cjs"),j=require("../graph/graph.cjs"),se=require("../graph/graph-view.cjs"),le=require("./graph-dropdown.cjs"),ce=({size:e=16})=>o.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-label":"Expand fullscreen",children:[o.jsx("title",{children:"Expand fullscreen"}),o.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"})]}),ue=({size:e=16})=>o.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-label":"Exit fullscreen",children:[o.jsx("title",{children:"Exit fullscreen"}),o.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"})]}),N="ui-kit:tradingview-series-colors:";function M(e){if(typeof window>"u"||!window.localStorage)return new Map;try{const t=window.localStorage.getItem(N+e);if(!t)return new Map;const c=JSON.parse(t);return c==null||typeof c!="object"?new Map:new Map(Object.entries(c).filter(([,r])=>typeof r=="number"&&r>=0&&r<j.DEFAULT_SERIES_COLORS.length))}catch{return new Map}}function ae(e,t){if(!(typeof window>"u"||!window.localStorage))try{window.localStorage.setItem(N+e,JSON.stringify(Object.fromEntries(t)))}catch{}}function q(e,t){if(t.size===0)return;const c=M(e);for(const[r,b]of t)c.set(r,b);ae(e,c)}function de({data:e,yMeasureUnit:t,height:c=306,defaultGraph:r,onGraphSelected:b,graphs:m,isMultipleSelect:T,range:V,rangeList:I,setRange:F,onGraphExpanded:y,isGraphExpanded:z,onUnselectSeries:B,graphsWithNoData:D,loadingGraphs:A,noDataMessage:R="No data available for this graph",currentValueDecimals:W,containerClassName:H,useSharedPriceScale:J,showCurrentValue:$,yScaleMin:Q,yScaleMinMultiple:X,seriesColorPersistenceKey:u,...Y}){const v=x.useMemo(()=>Array.isArray(e)?e:e?[e]:[],[e]),C=x.useMemo(()=>Array.isArray(e)&&e.length>1,[e]),k=ne.useIsMobile(),Z=x.useCallback((w,S)=>{re.toast.error(R)},[R]),U=x.useMemo(()=>{if(t)return Array.isArray(t)?t[0]:t},[t]),P=(!k&&y||I.length>0||b&&m&&r)&&o.jsxs("div",{className:"z-10 w-full flex flex-row flex-wrap sm:flex-nowrap items-center gap-2",children:[o.jsx("div",{children:b&&m&&r&&o.jsx(le.GraphDropdown,{onSelected:b,items:m,defaultItem:r,multiple:T,graphsWithNoData:D,loadingGraphs:A,onNoDataSelected:Z})}),o.jsxs("div",{className:"flex flex-row flex-nowrap justify-start sm:justify-end items-center flex-1",children:[o.jsx(ie.RangeButtons,{range:V,rangeList:I,setRange:F}),!k&&y&&o.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:y,children:z?o.jsx(ue,{size:16}):o.jsx(ce,{size:16})})]})]}),s=x.useRef(new Map),f=x.useRef(0),L=x.useRef(!1);if(m&&m.length>0&&!L.current){L.current=!0;const w=u?M(u):new Map,S=String(m[0].value);s.current.set(S,0),f.current=1;for(let n=1;n<m.length;n++){const a=String(m[n].value);if(s.current.has(a))continue;const h=w.get(a)??n;s.current.set(a,h),f.current=Math.max(f.current,h+1)}u&&q(u,s.current)}const K=x.useMemo(()=>{const w=Array.isArray(t)?t:void 0;if(u){const n=M(u);for(const[a,g]of n)s.current.has(a)||(s.current.set(a,g),f.current=Math.max(f.current,g+1))}const S=v.map((n,a)=>{const g=n?.title||`Series ${a+1}`,h=r!=null?Array.isArray(r)?r[0]?.value??r[0]:typeof r=="object"&&"value"in r?r.value:r:null,_=v.length===1?h!=null?String(h):"single":n?.id||g;if(!s.current.has(_)){const i=new Set(Array.from(s.current.values()));let l=f.current;for(let d=0;d<j.DEFAULT_SERIES_COLORS.length;d++){const p=(f.current+d)%j.DEFAULT_SERIES_COLORS.length;if(!i.has(p)){l=p;break}}s.current.set(_,l),f.current=l+1}const ee=s.current.get(_)??0,E=j.getSeriesColorPalette(ee),te=[...n?.data||[]].sort((i,l)=>{const d=typeof i.time=="number"?i.time:Number(i.time),p=typeof l.time=="number"?l.time:Number(l.time);return d-p}).reduce((i,l)=>{const d=l.time;return i.length===0||i[i.length-1].time!==d?i.push({time:d,value:l.value}):i[i.length-1]={time:d,value:l.value},i},[]),O=n?.lineColor??n?.color??void 0;return{data:te,label:g,yMeasureUnit:w?.[a]??(Array.isArray(t)?void 0:t),...O!=null?{lineColor:O,...n?.topColor!=null&&{topColor:n.topColor},...n?.bottomColor!=null&&{bottomColor:n.bottomColor}}:{color:E.line,topColor:E.top,bottomColor:E.bottom}}});return u&&s.current.size>0&&q(u,s.current),S},[v,r,t,u]),G=A!==void 0?A.size>0:C&&v.length>0?v.some(w=>!w):!e;return o.jsx("div",{style:{width:"100%",height:c?`${c}px`:void 0},className:"w-full",children:o.jsx(se.GraphViewWithData,{series:K,loading:G,toolbar:P,size:c?"full":"default",containerClassName:oe.cn("h-full",H),showLegend:C,onUnselectSeries:B,yMeasureUnit:U,currentValueDecimals:W,useSharedPriceScale:J,showCurrentValue:$,yScaleMin:Q,yScaleMinMultiple:X,...Y})})}exports.TradingView=de;
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { cva as
|
|
3
|
-
import * as
|
|
4
|
-
import { CurrencyButton as
|
|
5
|
-
import { faXmark as
|
|
6
|
-
import { FaIcon as
|
|
7
|
-
import { useIsMobile as
|
|
8
|
-
import { smartNumberInputTestIds as
|
|
9
|
-
import { bnToInputView as
|
|
1
|
+
import { jsxs as i, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { cva as b } from "class-variance-authority";
|
|
3
|
+
import * as c from "react";
|
|
4
|
+
import { CurrencyButton as U } from "../currency-button/currency-button.js";
|
|
5
|
+
import { faXmark as W } from "@fortawesome/free-solid-svg-icons";
|
|
6
|
+
import { FaIcon as Y } from "../icons/fa-icon.js";
|
|
7
|
+
import { useIsMobile as Z, useIsTablet as _, useIsDesktop as A } from "../../hooks/use-media-query.js";
|
|
8
|
+
import { smartNumberInputTestIds as m } from "../../test-ids/smart-number-input.js";
|
|
9
|
+
import { bnToInputView as ee } from "../../utils/bn-to-input-view.js";
|
|
10
10
|
import "@gearbox-protocol/sdk";
|
|
11
|
-
import { parseInputToBN as
|
|
12
|
-
import { cn as
|
|
11
|
+
import { parseInputToBN as te } from "../../utils/parse-input-to-bn.js";
|
|
12
|
+
import { cn as x } from "../../utils/cn.js";
|
|
13
13
|
import "sonner";
|
|
14
14
|
import "@gearbox-protocol/sdk/common-utils";
|
|
15
15
|
import "luxon";
|
|
16
16
|
import "../../utils/z-index.js";
|
|
17
|
-
import { BalanceIndicator as
|
|
18
|
-
const
|
|
17
|
+
import { BalanceIndicator as re } from "./balance-indicator.js";
|
|
18
|
+
const ae = b(
|
|
19
19
|
"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",
|
|
20
20
|
{
|
|
21
21
|
variants: {
|
|
@@ -26,7 +26,7 @@ const Y = m(
|
|
|
26
26
|
},
|
|
27
27
|
defaultVariants: { size: "md" }
|
|
28
28
|
}
|
|
29
|
-
),
|
|
29
|
+
), ne = b("font-medium text-foreground", {
|
|
30
30
|
variants: {
|
|
31
31
|
size: {
|
|
32
32
|
sm: "text-xs",
|
|
@@ -34,7 +34,7 @@ const Y = m(
|
|
|
34
34
|
}
|
|
35
35
|
},
|
|
36
36
|
defaultVariants: { size: "md" }
|
|
37
|
-
}),
|
|
37
|
+
}), se = b(
|
|
38
38
|
"w-full p-0 bg-transparent border-none outline-none text-foreground placeholder:text-secondary-foreground focus:outline-none",
|
|
39
39
|
{
|
|
40
40
|
variants: {
|
|
@@ -45,97 +45,107 @@ const Y = m(
|
|
|
45
45
|
},
|
|
46
46
|
defaultVariants: { size: "md" }
|
|
47
47
|
}
|
|
48
|
-
),
|
|
48
|
+
), oe = c.forwardRef(
|
|
49
49
|
({
|
|
50
|
-
amount:
|
|
51
|
-
token:
|
|
52
|
-
label:
|
|
53
|
-
maxAmount:
|
|
54
|
-
maxAmountLimit:
|
|
55
|
-
maxButtonLabel:
|
|
56
|
-
chainId:
|
|
57
|
-
network:
|
|
58
|
-
maxButton:
|
|
59
|
-
disabled:
|
|
60
|
-
active:
|
|
61
|
-
size:
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
50
|
+
amount: k,
|
|
51
|
+
token: a,
|
|
52
|
+
label: I = "Amount",
|
|
53
|
+
maxAmount: s,
|
|
54
|
+
maxAmountLimit: f,
|
|
55
|
+
maxButtonLabel: M,
|
|
56
|
+
chainId: V,
|
|
57
|
+
network: B,
|
|
58
|
+
maxButton: L = !0,
|
|
59
|
+
disabled: n = !1,
|
|
60
|
+
active: T = !1,
|
|
61
|
+
size: j = "md",
|
|
62
|
+
symbolMaxLength: F,
|
|
63
|
+
tokenOptions: p,
|
|
64
|
+
onSetAmount: o,
|
|
65
|
+
onShowSelectDialog: v,
|
|
66
|
+
onRemove: y,
|
|
67
|
+
onFocus: E,
|
|
68
|
+
onBlur: R
|
|
69
|
+
}, S) => {
|
|
70
|
+
const w = a?.decimals ?? 18, D = (e) => {
|
|
71
|
+
const r = e.target.value, [z, C] = te(r, w);
|
|
72
|
+
z === null || C === null || o && o(z, C);
|
|
73
|
+
}, O = () => {
|
|
74
|
+
if (o) {
|
|
75
|
+
const e = s && f && s > f ? f : s || 0n, r = ee(e, w);
|
|
76
|
+
o(e, r);
|
|
75
77
|
}
|
|
76
|
-
}, [
|
|
77
|
-
|
|
78
|
-
},
|
|
79
|
-
|
|
80
|
-
},
|
|
81
|
-
|
|
78
|
+
}, [X, N] = c.useState(!1), $ = () => {
|
|
79
|
+
N(!0), E?.();
|
|
80
|
+
}, q = () => {
|
|
81
|
+
N(!1), R?.();
|
|
82
|
+
}, l = j ?? "md", G = Z(), H = _(), J = A(), K = F ?? (G ? 20 : H ? 30 : J ? 22 : 30), [u, h] = c.useState(!1), g = c.useRef(null);
|
|
83
|
+
c.useEffect(() => {
|
|
84
|
+
if (!u) return;
|
|
85
|
+
const e = (r) => {
|
|
86
|
+
g.current && !g.current.contains(r.target) && h(!1);
|
|
87
|
+
};
|
|
88
|
+
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
89
|
+
}, [u]);
|
|
90
|
+
const d = !!(p && p.length > 0), P = !n && d ? () => h((e) => !e) : v, Q = !!(a || v || d);
|
|
91
|
+
return /* @__PURE__ */ i(
|
|
82
92
|
"div",
|
|
83
93
|
{
|
|
84
|
-
ref:
|
|
85
|
-
className:
|
|
86
|
-
"data-testid":
|
|
87
|
-
"data-active":
|
|
88
|
-
"data-disabled":
|
|
94
|
+
ref: S,
|
|
95
|
+
className: ae({ size: l }),
|
|
96
|
+
"data-testid": m.root,
|
|
97
|
+
"data-active": X,
|
|
98
|
+
"data-disabled": n,
|
|
89
99
|
children: [
|
|
90
|
-
|
|
100
|
+
y && /* @__PURE__ */ t(
|
|
91
101
|
"div",
|
|
92
102
|
{
|
|
93
103
|
className: "absolute top-0 right-0 flex h-5 w-5 translate-x-1/2 -translate-y-1/2 items-center justify-center",
|
|
94
|
-
"data-testid":
|
|
95
|
-
children: /* @__PURE__ */
|
|
104
|
+
"data-testid": m.close,
|
|
105
|
+
children: /* @__PURE__ */ t(
|
|
96
106
|
"button",
|
|
97
107
|
{
|
|
98
108
|
type: "button",
|
|
99
|
-
onClick:
|
|
109
|
+
onClick: y,
|
|
100
110
|
className: "flex h-5 w-5 items-center justify-center rounded-full bg-muted hover:bg-muted/80 text-muted-foreground",
|
|
101
|
-
children: /* @__PURE__ */
|
|
111
|
+
children: /* @__PURE__ */ t(Y, { icon: W, className: "size-3" })
|
|
102
112
|
}
|
|
103
113
|
)
|
|
104
114
|
}
|
|
105
115
|
),
|
|
106
|
-
/* @__PURE__ */
|
|
107
|
-
/* @__PURE__ */
|
|
116
|
+
/* @__PURE__ */ i("div", { className: "mb-2 flex justify-between text-sm leading-[120%]", children: [
|
|
117
|
+
/* @__PURE__ */ t(
|
|
108
118
|
"span",
|
|
109
119
|
{
|
|
110
|
-
className:
|
|
111
|
-
|
|
120
|
+
className: x(
|
|
121
|
+
ne({ size: l }),
|
|
112
122
|
"grow shrink-0 basis-0"
|
|
113
123
|
),
|
|
114
|
-
"data-testid":
|
|
115
|
-
children:
|
|
124
|
+
"data-testid": m.label,
|
|
125
|
+
children: I
|
|
116
126
|
}
|
|
117
127
|
),
|
|
118
|
-
|
|
119
|
-
|
|
128
|
+
s !== void 0 && a && /* @__PURE__ */ t(
|
|
129
|
+
re,
|
|
120
130
|
{
|
|
121
|
-
title:
|
|
122
|
-
token:
|
|
123
|
-
maxAmount:
|
|
124
|
-
size:
|
|
125
|
-
disabled:
|
|
126
|
-
maxButton:
|
|
127
|
-
onMaxButtonClick:
|
|
131
|
+
title: M,
|
|
132
|
+
token: a,
|
|
133
|
+
maxAmount: s,
|
|
134
|
+
size: l,
|
|
135
|
+
disabled: n,
|
|
136
|
+
maxButton: L,
|
|
137
|
+
onMaxButtonClick: O
|
|
128
138
|
}
|
|
129
139
|
)
|
|
130
140
|
] }),
|
|
131
|
-
/* @__PURE__ */
|
|
141
|
+
/* @__PURE__ */ i(
|
|
132
142
|
"div",
|
|
133
143
|
{
|
|
134
|
-
className:
|
|
144
|
+
className: x(
|
|
135
145
|
"flex w-full max-w-full shrink-0 basis-full items-center"
|
|
136
146
|
),
|
|
137
147
|
children: [
|
|
138
|
-
/* @__PURE__ */
|
|
148
|
+
/* @__PURE__ */ t("div", { className: "mr-3 grow shrink-0 basis-0", children: /* @__PURE__ */ t(
|
|
139
149
|
"input",
|
|
140
150
|
{
|
|
141
151
|
type: "text",
|
|
@@ -145,35 +155,52 @@ const Y = m(
|
|
|
145
155
|
spellCheck: "false",
|
|
146
156
|
pattern: "^[0-9]*[.,]?[0-9]*$",
|
|
147
157
|
placeholder: "0",
|
|
148
|
-
value:
|
|
149
|
-
onChange:
|
|
150
|
-
onFocus:
|
|
151
|
-
onBlur:
|
|
152
|
-
disabled:
|
|
153
|
-
className:
|
|
154
|
-
|
|
155
|
-
|
|
158
|
+
value: k,
|
|
159
|
+
onChange: D,
|
|
160
|
+
onFocus: $,
|
|
161
|
+
onBlur: q,
|
|
162
|
+
disabled: n || !o,
|
|
163
|
+
className: x(
|
|
164
|
+
se({ size: l }),
|
|
165
|
+
n && "cursor-not-allowed"
|
|
156
166
|
),
|
|
157
|
-
"data-testid":
|
|
167
|
+
"data-testid": m.input,
|
|
158
168
|
minLength: 1,
|
|
159
169
|
maxLength: 79,
|
|
160
170
|
title: "Amount"
|
|
161
171
|
}
|
|
162
172
|
) }),
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
173
|
+
Q ? /* @__PURE__ */ i("div", { ref: g, className: "relative shrink-0", children: [
|
|
174
|
+
/* @__PURE__ */ t(
|
|
175
|
+
U,
|
|
176
|
+
{
|
|
177
|
+
active: d ? u : T,
|
|
178
|
+
size: l,
|
|
179
|
+
disabled: n,
|
|
180
|
+
token: a,
|
|
181
|
+
showSelectDialog: P,
|
|
182
|
+
chainId: V,
|
|
183
|
+
network: B,
|
|
184
|
+
maxLength: K,
|
|
185
|
+
children: a?.symbol ?? "Select token"
|
|
186
|
+
}
|
|
187
|
+
),
|
|
188
|
+
d && u && /* @__PURE__ */ t("div", { className: "absolute right-0 top-full z-20 mt-1 min-w-[140px] overflow-hidden rounded-lg border border-gray-30 bg-gray-20 shadow-lg", children: p?.map((e, r) => /* @__PURE__ */ i(
|
|
189
|
+
"button",
|
|
190
|
+
{
|
|
191
|
+
type: "button",
|
|
192
|
+
onClick: () => {
|
|
193
|
+
e.onSelect(), h(!1);
|
|
194
|
+
},
|
|
195
|
+
className: "flex w-full items-center gap-2 px-3 py-2 text-sm text-foreground hover:bg-gray-30 text-left",
|
|
196
|
+
children: [
|
|
197
|
+
e.icon ? /* @__PURE__ */ t("span", { className: "inline-flex shrink-0 items-center", children: e.icon }) : null,
|
|
198
|
+
/* @__PURE__ */ t("span", { className: "truncate", children: e.label })
|
|
199
|
+
]
|
|
200
|
+
},
|
|
201
|
+
r
|
|
202
|
+
)) })
|
|
203
|
+
] }) : null
|
|
177
204
|
]
|
|
178
205
|
}
|
|
179
206
|
)
|
|
@@ -182,7 +209,7 @@ const Y = m(
|
|
|
182
209
|
);
|
|
183
210
|
}
|
|
184
211
|
);
|
|
185
|
-
|
|
212
|
+
oe.displayName = "SmartNumberInput";
|
|
186
213
|
export {
|
|
187
|
-
|
|
214
|
+
oe as SmartNumberInput
|
|
188
215
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsxs as S, jsx as l } from "react/jsx-runtime";
|
|
2
|
-
import { useMemo as y, useCallback as ne, useRef as
|
|
2
|
+
import { useMemo as y, useCallback as ne, useRef as E } from "react";
|
|
3
3
|
import { toast as ie } from "sonner";
|
|
4
4
|
import { useIsMobile as le } from "../../hooks/use-media-query.js";
|
|
5
5
|
import "@gearbox-protocol/sdk";
|
|
@@ -8,7 +8,7 @@ import "@gearbox-protocol/sdk/common-utils";
|
|
|
8
8
|
import "luxon";
|
|
9
9
|
import "../../utils/z-index.js";
|
|
10
10
|
import { RangeButtons as ce } from "../buttons/range-buttons/range-buttons.js";
|
|
11
|
-
import { DEFAULT_SERIES_COLORS as
|
|
11
|
+
import { DEFAULT_SERIES_COLORS as k, getSeriesColorPalette as ue } from "../graph/graph.js";
|
|
12
12
|
import { GraphViewWithData as me } from "../graph/graph-view.js";
|
|
13
13
|
import { GraphDropdown as fe } from "./graph-dropdown.js";
|
|
14
14
|
const de = ({ size: e = 16 }) => /* @__PURE__ */ S(
|
|
@@ -45,17 +45,17 @@ const de = ({ size: e = 16 }) => /* @__PURE__ */ S(
|
|
|
45
45
|
/* @__PURE__ */ l("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" })
|
|
46
46
|
]
|
|
47
47
|
}
|
|
48
|
-
),
|
|
49
|
-
function
|
|
48
|
+
), V = "ui-kit:tradingview-series-colors:";
|
|
49
|
+
function j(e) {
|
|
50
50
|
if (typeof window > "u" || !window.localStorage)
|
|
51
51
|
return /* @__PURE__ */ new Map();
|
|
52
52
|
try {
|
|
53
|
-
const t = window.localStorage.getItem(
|
|
53
|
+
const t = window.localStorage.getItem(V + e);
|
|
54
54
|
if (!t) return /* @__PURE__ */ new Map();
|
|
55
55
|
const c = JSON.parse(t);
|
|
56
56
|
return c == null || typeof c != "object" ? /* @__PURE__ */ new Map() : new Map(
|
|
57
57
|
Object.entries(c).filter(
|
|
58
|
-
([, o]) => typeof o == "number" && o >= 0 && o <
|
|
58
|
+
([, o]) => typeof o == "number" && o >= 0 && o < k.length
|
|
59
59
|
)
|
|
60
60
|
);
|
|
61
61
|
} catch {
|
|
@@ -66,17 +66,17 @@ function we(e, t) {
|
|
|
66
66
|
if (!(typeof window > "u" || !window.localStorage))
|
|
67
67
|
try {
|
|
68
68
|
window.localStorage.setItem(
|
|
69
|
-
|
|
69
|
+
V + e,
|
|
70
70
|
JSON.stringify(Object.fromEntries(t))
|
|
71
71
|
);
|
|
72
72
|
} catch {
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
|
-
function
|
|
75
|
+
function F(e, t) {
|
|
76
76
|
if (t.size === 0) return;
|
|
77
|
-
const c =
|
|
78
|
-
for (const [o,
|
|
79
|
-
c.set(o,
|
|
77
|
+
const c = j(e);
|
|
78
|
+
for (const [o, v] of t)
|
|
79
|
+
c.set(o, v);
|
|
80
80
|
we(e, c);
|
|
81
81
|
}
|
|
82
82
|
function Re({
|
|
@@ -84,18 +84,18 @@ function Re({
|
|
|
84
84
|
yMeasureUnit: t,
|
|
85
85
|
height: c = 306,
|
|
86
86
|
defaultGraph: o,
|
|
87
|
-
onGraphSelected:
|
|
87
|
+
onGraphSelected: v,
|
|
88
88
|
graphs: d,
|
|
89
|
-
isMultipleSelect:
|
|
90
|
-
range:
|
|
91
|
-
rangeList:
|
|
92
|
-
setRange:
|
|
89
|
+
isMultipleSelect: B,
|
|
90
|
+
range: T,
|
|
91
|
+
rangeList: N,
|
|
92
|
+
setRange: D,
|
|
93
93
|
onGraphExpanded: A,
|
|
94
|
-
isGraphExpanded:
|
|
95
|
-
onUnselectSeries:
|
|
96
|
-
graphsWithNoData:
|
|
97
|
-
loadingGraphs:
|
|
98
|
-
noDataMessage:
|
|
94
|
+
isGraphExpanded: W,
|
|
95
|
+
onUnselectSeries: H,
|
|
96
|
+
graphsWithNoData: J,
|
|
97
|
+
loadingGraphs: I,
|
|
98
|
+
noDataMessage: R = "No data available for this graph",
|
|
99
99
|
currentValueDecimals: $,
|
|
100
100
|
containerClassName: X,
|
|
101
101
|
useSharedPriceScale: q,
|
|
@@ -105,51 +105,51 @@ function Re({
|
|
|
105
105
|
seriesColorPersistenceKey: u,
|
|
106
106
|
...U
|
|
107
107
|
}) {
|
|
108
|
-
const
|
|
108
|
+
const b = y(() => Array.isArray(e) ? e : e ? [e] : [], [e]), L = y(() => Array.isArray(e) && e.length > 1, [e]), O = le(), K = ne(
|
|
109
109
|
(w, g) => {
|
|
110
|
-
ie.error(
|
|
110
|
+
ie.error(R);
|
|
111
111
|
},
|
|
112
|
-
[
|
|
112
|
+
[R]
|
|
113
113
|
), P = y(() => {
|
|
114
114
|
if (t)
|
|
115
115
|
return Array.isArray(t) ? t[0] : t;
|
|
116
|
-
}, [t]), G = (!
|
|
117
|
-
/* @__PURE__ */ l("div", { children:
|
|
116
|
+
}, [t]), G = (!O && A || N.length > 0 || v && d && o) && /* @__PURE__ */ S("div", { className: "z-10 w-full flex flex-row flex-wrap sm:flex-nowrap items-center gap-2", children: [
|
|
117
|
+
/* @__PURE__ */ l("div", { children: v && d && o && /* @__PURE__ */ l(
|
|
118
118
|
fe,
|
|
119
119
|
{
|
|
120
|
-
onSelected:
|
|
120
|
+
onSelected: v,
|
|
121
121
|
items: d,
|
|
122
122
|
defaultItem: o,
|
|
123
|
-
multiple:
|
|
124
|
-
graphsWithNoData:
|
|
125
|
-
loadingGraphs:
|
|
123
|
+
multiple: B,
|
|
124
|
+
graphsWithNoData: J,
|
|
125
|
+
loadingGraphs: I,
|
|
126
126
|
onNoDataSelected: K
|
|
127
127
|
}
|
|
128
128
|
) }),
|
|
129
129
|
/* @__PURE__ */ S("div", { className: "flex flex-row flex-nowrap justify-start sm:justify-end items-center flex-1", children: [
|
|
130
|
-
/* @__PURE__ */ l(ce, { range:
|
|
131
|
-
!
|
|
130
|
+
/* @__PURE__ */ l(ce, { range: T, rangeList: N, setRange: D }),
|
|
131
|
+
!O && A && /* @__PURE__ */ l(
|
|
132
132
|
"button",
|
|
133
133
|
{
|
|
134
134
|
type: "button",
|
|
135
135
|
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",
|
|
136
136
|
onClick: A,
|
|
137
|
-
children:
|
|
137
|
+
children: W ? /* @__PURE__ */ l(ae, { size: 16 }) : /* @__PURE__ */ l(de, { size: 16 })
|
|
138
138
|
}
|
|
139
139
|
)
|
|
140
140
|
] })
|
|
141
|
-
] }), i =
|
|
142
|
-
if (d && d.length > 0 && !
|
|
143
|
-
|
|
144
|
-
const w = u ?
|
|
141
|
+
] }), i = E(/* @__PURE__ */ new Map()), a = E(0), _ = E(!1);
|
|
142
|
+
if (d && d.length > 0 && !_.current) {
|
|
143
|
+
_.current = !0;
|
|
144
|
+
const w = u ? j(u) : /* @__PURE__ */ new Map(), g = String(d[0].value);
|
|
145
145
|
i.current.set(g, 0), a.current = 1;
|
|
146
146
|
for (let r = 1; r < d.length; r++) {
|
|
147
147
|
const m = String(d[r].value);
|
|
148
148
|
if (i.current.has(m)) continue;
|
|
149
|
-
const
|
|
150
|
-
i.current.set(m,
|
|
149
|
+
const p = w.get(m) ?? r;
|
|
150
|
+
i.current.set(m, p), a.current = Math.max(a.current, p + 1);
|
|
151
151
|
}
|
|
152
|
-
u &&
|
|
152
|
+
u && F(
|
|
153
153
|
u,
|
|
154
154
|
i.current
|
|
155
155
|
);
|
|
@@ -157,42 +157,42 @@ function Re({
|
|
|
157
157
|
const ee = y(() => {
|
|
158
158
|
const w = Array.isArray(t) ? t : void 0;
|
|
159
159
|
if (u) {
|
|
160
|
-
const r =
|
|
160
|
+
const r = j(u);
|
|
161
161
|
for (const [m, x] of r)
|
|
162
162
|
i.current.has(m) || (i.current.set(m, x), a.current = Math.max(
|
|
163
163
|
a.current,
|
|
164
164
|
x + 1
|
|
165
165
|
));
|
|
166
166
|
}
|
|
167
|
-
const g =
|
|
168
|
-
const x = r?.title || `Series ${m + 1}`,
|
|
169
|
-
if (!i.current.has(
|
|
167
|
+
const g = b.map((r, m) => {
|
|
168
|
+
const x = r?.title || `Series ${m + 1}`, p = o != null ? Array.isArray(o) ? o[0]?.value ?? o[0] : typeof o == "object" && "value" in o ? o.value : o : null, C = b.length === 1 ? p != null ? String(p) : "single" : r?.id || x;
|
|
169
|
+
if (!i.current.has(C)) {
|
|
170
170
|
const n = new Set(
|
|
171
171
|
Array.from(i.current.values())
|
|
172
172
|
);
|
|
173
173
|
let s = a.current;
|
|
174
|
-
for (let f = 0; f <
|
|
175
|
-
const h = (a.current + f) %
|
|
174
|
+
for (let f = 0; f < k.length; f++) {
|
|
175
|
+
const h = (a.current + f) % k.length;
|
|
176
176
|
if (!n.has(h)) {
|
|
177
177
|
s = h;
|
|
178
178
|
break;
|
|
179
179
|
}
|
|
180
180
|
}
|
|
181
|
-
i.current.set(
|
|
181
|
+
i.current.set(C, s), a.current = s + 1;
|
|
182
182
|
}
|
|
183
|
-
const oe = i.current.get(
|
|
183
|
+
const oe = i.current.get(C) ?? 0, M = ue(oe), re = [...r?.data || []].sort((n, s) => {
|
|
184
184
|
const f = typeof n.time == "number" ? n.time : Number(n.time), h = typeof s.time == "number" ? s.time : Number(s.time);
|
|
185
185
|
return f - h;
|
|
186
186
|
}).reduce((n, s) => {
|
|
187
187
|
const f = s.time;
|
|
188
188
|
return n.length === 0 || n[n.length - 1].time !== f ? n.push({ time: f, value: s.value }) : n[n.length - 1] = { time: f, value: s.value }, n;
|
|
189
|
-
}, []),
|
|
189
|
+
}, []), z = r?.lineColor ?? r?.color ?? void 0;
|
|
190
190
|
return {
|
|
191
191
|
data: re,
|
|
192
192
|
label: x,
|
|
193
193
|
yMeasureUnit: w?.[m] ?? (Array.isArray(t) ? void 0 : t),
|
|
194
|
-
...
|
|
195
|
-
lineColor:
|
|
194
|
+
...z != null ? {
|
|
195
|
+
lineColor: z,
|
|
196
196
|
...r?.topColor != null && {
|
|
197
197
|
topColor: r.topColor
|
|
198
198
|
},
|
|
@@ -200,17 +200,17 @@ function Re({
|
|
|
200
200
|
bottomColor: r.bottomColor
|
|
201
201
|
}
|
|
202
202
|
} : {
|
|
203
|
-
color:
|
|
204
|
-
topColor:
|
|
205
|
-
bottomColor:
|
|
203
|
+
color: M.line,
|
|
204
|
+
topColor: M.top,
|
|
205
|
+
bottomColor: M.bottom
|
|
206
206
|
}
|
|
207
207
|
};
|
|
208
208
|
});
|
|
209
|
-
return u && i.current.size > 0 &&
|
|
209
|
+
return u && i.current.size > 0 && F(
|
|
210
210
|
u,
|
|
211
211
|
i.current
|
|
212
212
|
), g;
|
|
213
|
-
}, [
|
|
213
|
+
}, [b, o, t, u]), te = I !== void 0 ? I.size > 0 : L && b.length > 0 ? b.some((w) => !w) : !e;
|
|
214
214
|
return /* @__PURE__ */ l(
|
|
215
215
|
"div",
|
|
216
216
|
{
|
|
@@ -227,8 +227,8 @@ function Re({
|
|
|
227
227
|
toolbar: G,
|
|
228
228
|
size: c ? "full" : "default",
|
|
229
229
|
containerClassName: se("h-full", X),
|
|
230
|
-
showLegend:
|
|
231
|
-
onUnselectSeries:
|
|
230
|
+
showLegend: L,
|
|
231
|
+
onUnselectSeries: H,
|
|
232
232
|
yMeasureUnit: P,
|
|
233
233
|
currentValueDecimals: $,
|
|
234
234
|
useSharedPriceScale: q,
|