@gearbox-protocol/ui-kit 3.14.0-next.3 → 3.14.0-next.5
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/locale/en.json.cjs +1 -1
- package/dist/esm/components/smart-number-input/smart-number-input.js +205 -120
- package/dist/esm/locale/en.json.js +2 -0
- package/dist/globals.css +1 -1
- package/dist/types/components/smart-number-input/smart-number-input.d.ts +22 -1
- package/dist/types/locale/en.json.d.ts +2 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),j=require("class-variance-authority"),re=require("react"),ae=require("react-dom"),oe=require("../checkbox/checkbox.cjs");require("../checkbox/checkbox-labeled.cjs");const ce=require("../currency-button/currency-button.cjs"),ie=require("@fortawesome/free-solid-svg-icons"),le=require("../icons/fa-icon.cjs"),I=require("../typed-intl/index.cjs"),N=require("../../hooks/use-media-query.cjs"),b=require("../../test-ids/smart-number-input.cjs"),ue=require("../../utils/bn-to-input-view.cjs");require("@gearbox-protocol/sdk");const de=require("../../utils/parse-input-to-bn.cjs"),y=require("../../utils/cn.cjs");require("sonner");require("@gearbox-protocol/sdk/common-utils");require("luxon");require("../../utils/z-index.cjs");const me=require("./balance-indicator.cjs");function fe(a){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const o in a)if(o!=="default"){const r=Object.getOwnPropertyDescriptor(a,o);Object.defineProperty(s,o,r.get?r:{enumerable:!0,get:()=>a[o]})}}return s.default=a,Object.freeze(s)}const c=fe(re),pe=j.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] min-h-[60px] rounded-[8px]",md:"pl-4 pr-3 py-[10px] min-h-[82px] rounded-lg"}},defaultVariants:{size:"md"}}),he=j.cva("font-medium text-foreground",{variants:{size:{sm:"text-xs",md:"text-sm"}},defaultVariants:{size:"md"}}),xe=j.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"}});function ge(a,s){const o=parseFloat(a.replace(",",".")||"0");if(!Number.isFinite(o)||o===0)return"$0";const r=o*s,h=Math.abs(r)<100;try{return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:h?2:0,maximumFractionDigits:h?2:0}).format(r)}catch{return"$0"}}const M=c.forwardRef(({amount:a,token:s,label:o,maxAmount:r,maxAmountLimit:p,maxButtonLabel:h,chainId:S,network:L,maxButton:B=!0,disabled:u=!1,active:F=!1,size:V="md",symbolMaxLength:D,tokenOptions:v,multiSelectMode:R=!1,onSetAmount:m,onShowSelectDialog:k,onRemove:q,onFocus:E,onBlur:O,usdPrice:z},$)=>{const{formatMessage:P}=I.useIntlTyped(),U=c.useId(),C=s?.decimals??18,W=e=>{const n=e.target.value,[i,l]=de.parseInputToBN(n,C);i===null||l===null||m&&m(i,l)},Q=()=>{if(m){const e=r&&p&&r>p?p:r||0n,n=ue.bnToInputView(e,C);m(e,n)}},[X,T]=c.useState(!1),G=()=>{T(!0),E?.()},H=()=>{T(!1),O?.()},f=V??"md",J=N.useIsMobile(),K=N.useIsTablet(),Y=N.useIsDesktop(),Z=D??(J?20:K?30:Y?22:30),[d,w]=c.useState(!1),x=c.useRef(null),_=c.useRef(null),[A,ee]=c.useState({});c.useLayoutEffect(()=>{if(!d||!x.current)return;const e=()=>{const n=x.current?.getBoundingClientRect();n&&ee({position:"fixed",top:n.bottom+4,right:window.innerWidth-n.right,minWidth:n.width,zIndex:9999})};return e(),window.addEventListener("scroll",e,!0),window.addEventListener("resize",e),()=>{window.removeEventListener("scroll",e,!0),window.removeEventListener("resize",e)}},[d]),c.useEffect(()=>{if(!d)return;const e=n=>{const i=n.target,l=x.current?.contains(i),se=_.current?.contains(i);!l&&!se&&w(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[d]);const g=!!(v&&v.length>0),te=!u&&g?()=>w(e=>!e):k,ne=!!(s||k||g);return t.jsxs("div",{ref:$,className:pe({size:f}),"data-testid":b.smartNumberInputTestIds.root,"data-active":X,"data-disabled":u,children:[q&&t.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":b.smartNumberInputTestIds.close,children:t.jsx("button",{type:"button",onClick:q,className:"flex h-5 w-5 items-center justify-center rounded-full bg-muted hover:bg-muted/80 text-muted-foreground",children:t.jsx(le.FaIcon,{icon:ie.faXmark,className:"size-3"})})}),t.jsxs("div",{className:"mb-2 flex justify-between text-sm leading-[120%]",children:[t.jsx("span",{className:y.cn(he({size:f}),"grow shrink-0 basis-0"),"data-testid":b.smartNumberInputTestIds.label,children:o??t.jsx(I.FormattedMessageTyped,{messageId:"components.smartNumberInput.amountLabel"})}),r!==void 0&&s&&t.jsx(me.BalanceIndicator,{title:h,token:s,maxAmount:r,size:f,disabled:u,maxButton:B,onMaxButtonClick:Q})]}),t.jsxs("div",{className:y.cn("flex w-full max-w-full shrink-0 basis-full items-center"),children:[t.jsx("div",{className:"mr-3 grow shrink-0 basis-0",children:t.jsx("input",{type:"text",inputMode:"decimal",autoComplete:"off",autoCorrect:"off",spellCheck:"false",pattern:"^[0-9]*[.,]?[0-9]*$",placeholder:"0",value:a,onChange:W,onFocus:G,onBlur:H,disabled:u||!m,className:y.cn(xe({size:f}),u&&"cursor-not-allowed"),"data-testid":b.smartNumberInputTestIds.input,minLength:1,maxLength:79,title:P({messageId:"components.smartNumberInput.inputTitle"})})}),ne?t.jsxs("div",{ref:x,className:"shrink-0",children:[t.jsx(ce.CurrencyButton,{active:g?d:F,size:f,disabled:u,token:s,showSelectDialog:te,chainId:S,network:L,maxLength:Z,children:s?.symbol??t.jsx(I.FormattedMessageTyped,{messageId:"components.smartNumberInput.selectToken"})}),g&&d&&ae.createPortal(t.jsx("div",{ref:_,style:A,className:"overflow-hidden rounded-lg border border-gray-30 bg-gray-20 shadow-lg",children:v?.map((e,n)=>{const i=`${U}-${n}`,l="flex w-full min-w-0 items-center gap-2 px-3 py-2 text-sm text-foreground hover:bg-gray-30";return R?t.jsxs("div",{className:l,children:[t.jsx(oe.Checkbox,{id:i,checked:!!e.checked,color:"secondary",size:"md",className:"shrink-0",onCheckedChange:()=>e.onSelect()}),t.jsxs("label",{htmlFor:i,className:"flex min-w-0 flex-1 cursor-pointer items-center gap-2 text-left",children:[e.icon?t.jsx("span",{className:"inline-flex shrink-0 items-center",children:e.icon}):null,t.jsx("span",{className:"truncate",children:e.label})]})]},n):t.jsxs("button",{type:"button",onClick:()=>{e.onSelect(),w(!1)},className:y.cn(l,"text-left"),children:[e.icon?t.jsx("span",{className:"inline-flex shrink-0 items-center",children:e.icon}):null,t.jsx("span",{className:"truncate",children:e.label})]},n)})}),document.body)]}):null]}),z!==void 0&&t.jsx("div",{className:"mt-1 text-xs leading-[130%] text-secondary-foreground",children:ge(a,z)})]})});M.displayName="SmartNumberInput";exports.SmartNumberInput=M;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e={"errors.networkError":"Network error. Can't fetch data","errors.incorrectAddressError":"Incorrect address. Please, check url","errors.noOpenedAccountsError":"You have no opened Credit Accounts. Perhaps, you have recently been liquidated? Check notification centre to see more.","errors.notFound":"Not found","errors.tooManyRequests":"Too many requests","errors.incorrectAddress":"Incorrect address","components.errorMessage.oops":"Oops...","components.alertModal.ok":"Ok","components.footer.privacy":"Privacy Notice","components.footer.terms":"Terms of Service","components.footer.disclosure":"Risk Disclosure Statement","components.footer.legalNotice":"Legal Notice","components.footer.legal":"Legal Info","components.footer.gearbox":"Copyright © Gearbox Foundation 2023-2026.","components.footer.built":"Built at ETHGlobal MarketMake hackathon.","components.footer.version":"Version {value}","components.liquidationPrice.check":"Check Area","components.loading.loading":"Loading","components.loading.loadingPercent":"Loading {percent}%","components.loading.wait":"Please wait...","components.smartNumberInput.balance":"Balance","components.smartNumberInput.inputTitle":"Token Amount","components.smartNumberInput.confirm.input":"Input","components.tipWindow.title":"Tip","components.healthFactor.low":"Extremely low! This HF may not cover possible oracle deviations.","components.headCell":"Sort by {value}","components.graphView.noData":"Can't get data for this graph","components.filterBlock.reset":"Reset All","components.filterModal.searchPlaceholder":"Search options...","components.filterModal.noOptionsAvailable":"No options available","components.filterModal.noOptionsMatchSearch":"No options match your search","components.filterModal.reset":"Reset","components.filterModal.apply":"Apply","components.APY.tip":"These APYs are derived from the underlying protocols’ APIs and may differ in reality. Check respective protocols for their methodology.","components.creditSessionDetailedLiquidation.graph.noData":"No data","components.creditSessionDetailedLiquidation.graph.legend.point":"Current price","components.creditSessionDetailedLiquidation.graph.legend.area":"Liquidation Area","components.creditSessionDetailedLiquidation.graph.tip.hf":"Health Factor","components.creditSessionDetailedLiquidation.graph.tip.price":"Price","components.creditSessionDetailedLiquidation.table.noData":"No data","components.creditSessionDetailedLiquidation.table.seeGraph":"See graph","components.creditSessionDetailedLiquidation.table.asset":"Asset","components.creditSessionDetailedLiquidation.table.currentPrice":"Current price","components.creditSessionDetailedLiquidation.table.modelPrice":"Model price","components.apyParts.features.points":"Points","components.apyParts.features.incent":"Incent.","components.apyParts.supplyAPY":"Organic APY","components.apyParts.title":"APY type","components.apyParts.supplyAPY.tip":"Yield from lending funds","components.apyParts.tokenYield":"Intrinsic APY","components.apyParts.tokenYield.tip":"Yield from holding wstETH","components.apyParts.extraAPY":"{symbol} Incentive","components.apyParts.extraAPY.tip":"Calculated at the current rate","components.apyParts.totalAPY":"Overall APY","components.apyParts.points":"{symbol} Incentive","components.apyParts.points.condition.crossDeposit":"For cross-chain deposits made via Omni","components.openCopyButtons.copy":"Copy to clipboard","components.poolAssetsTable.asset":"Asset","components.poolAssetsTable.rate":"Effective rate","components.poolAssetsTable.limits":"Limits Usage","components.poolAssetsTable.usage":"{amount} of {total}","components.poolAssetsTable.head.name":"Credit Manager","components.poolAssetsTable.head.currentDebt":"Current Debt","components.poolAssetsTable.head.assets":"Asset LT","components.poolCreditManagersTable.assets":"{amount} assets","components.creditManagerInfo.title":"Assets and LT’s","components.creditManagerInfo.info.title":"Credit Managers","components.creditManagerInfo.info.copy.tip":"Copy Credit Manager address","components.creditManagerInfo.info.minDebt":"Min debt","components.creditManagerInfo.info.maxDebt":"Max debt","components.creditManagerInfo.info.liquidationFee":"Liquid. fee","components.creditManagerInfo.info.liquidationPremium":"Liquid. premium","components.creditManagerInfo.info.interestFee":"Interest fee","components.creditManagerInfo.info.debtLimit":"Debt limit","components.creditManagerInfo.info.maxEnabledTokens":"Max tokens","dialogs.oraclesAndLTInfo.filter.hide0Quota":"Hide 0-Quota","components.oraclesAndLTInfo.title":"Oracles and LTs","components.oraclesAndLTTable.head.token":"Token","components.oraclesAndLTTable.head.oracles":"Oracles","components.oraclesAndLTTable.head.lt":"LT","components.poolTable.pool":"Market","components.poolTable.market":"Market","components.poolTable.description.universal":"Universal","components.poolTable.supply":"Supply","components.poolTable.borrowed":"Borrowed","components.poolTable.supplyApy":"Supply APY","components.poolTable.supplyApy.tip":"Annual percentage yield that you earn for supplying capital. This number constantly changes as the utilization of the Markets goes up and down","components.poolTable.depositApy":"Deposit APY","components.poolTable.depositApy.tip":"Deposit APY breakdown: base rate, extra rewards, and points","components.poolTable.borrowApy":"Borrow APY","components.poolTable.utilizationApy":"Utilization APY","components.poolTable.borrowApy.tip":"On top of the utilization borrow APY, there is a borrow quota APY for different assets","components.poolTable.utilization":"Utilization","components.poolTable.collateral":"Collateral","components.poolTable.collateral.showAll":"Show All","components.poolTable.balance":"Your Balance","components.poolTable.balance.tip":`You don't earn token rewards, only organic yield. Please migrate liquidity by using "Migrate" flow above.`,"components.poolTable.emptyList":"No Pools found","components.poolTable.notFound.dashboard":"You currently have no open Market positions.","components.poolTable.notFound.list":"No Markets found","components.poolTable.notFound.description.dashboard":"Choose earn above.","components.poolTable.notFound.description.list":"Choose another chain or toggle Show All Markets","components.poolTable.externalApy.tooltipShort":"{value} APY boost when depositing via {name}","components.poolTable.line.rwa.tip":"This is RWA market.","components.rewardsTooltip.without.title":"Without Leverage","components.rewardsTooltip.without.extra":"Extra APY","components.rewardsTooltip.without.extra.tip":"Any deposit through Gearbox","components.rewardsTooltip.with.title":"With {leverage} Leverage","components.rewardsTooltip.with.borrowRate":"{symbol} borrow rate","components.rewardsTooltip.with.quotaRate":"Quota rate","components.rewardsTooltip.with.bonusAPY.title":"Target Bonuses Yield","components.rewardsTooltip.with.bonusAPY.tip":"Expected Bonuses APY is calculated by the Asset Issuer and represents the expected value to be paid out in points.","components.rewardsTooltip.with.extra":"+ Extra APR","components.rewardsTooltip.button":"Click to show rewards details","components.strategiesTable.head.name":"Strategy","components.strategiesTable.head.rewards":"Rewards","components.strategiesTable.head.leverage":"Max Leverage","components.strategiesTable.head.earn":"You Can Earn","components.strategiesTable.body.notFound":"No strategy found","components.strategiesTable.line.disabled":"This strategy is currently not available, cause of lack or quota or liquidity. Please contact us on Discord, and we’ll assist you.","components.strategiesTable.line.name.disabled":"This strategy is currently not available","components.strategiesTable.line.points.tip":"For debt nominated in {symbol}","components.strategiesTable.line.points.tipAny":"For debt","components.strategiesTable.line.0slippage":"0-slippage","components.strategiesTable.line.0slippage.tip":"Wrapping/unwrapping happens directly through smart-contracts, so {symbol} deposits and withdrawals don't incur slippage.","components.strategiesTable.line.rwa":"RWA","components.strategiesTable.line.rwa.tip":"This strategy is available on RWA market."};module.exports=e;
|
|
1
|
+
"use strict";const e={"errors.networkError":"Network error. Can't fetch data","errors.incorrectAddressError":"Incorrect address. Please, check url","errors.noOpenedAccountsError":"You have no opened Credit Accounts. Perhaps, you have recently been liquidated? Check notification centre to see more.","errors.notFound":"Not found","errors.tooManyRequests":"Too many requests","errors.incorrectAddress":"Incorrect address","components.errorMessage.oops":"Oops...","components.alertModal.ok":"Ok","components.footer.privacy":"Privacy Notice","components.footer.terms":"Terms of Service","components.footer.disclosure":"Risk Disclosure Statement","components.footer.legalNotice":"Legal Notice","components.footer.legal":"Legal Info","components.footer.gearbox":"Copyright © Gearbox Foundation 2023-2026.","components.footer.built":"Built at ETHGlobal MarketMake hackathon.","components.footer.version":"Version {value}","components.liquidationPrice.check":"Check Area","components.loading.loading":"Loading","components.loading.loadingPercent":"Loading {percent}%","components.loading.wait":"Please wait...","components.smartNumberInput.balance":"Balance","components.smartNumberInput.amountLabel":"Amount","components.smartNumberInput.inputTitle":"Token Amount","components.smartNumberInput.confirm.input":"Input","components.smartNumberInput.selectToken":"Select token","components.tipWindow.title":"Tip","components.healthFactor.low":"Extremely low! This HF may not cover possible oracle deviations.","components.headCell":"Sort by {value}","components.graphView.noData":"Can't get data for this graph","components.filterBlock.reset":"Reset All","components.filterModal.searchPlaceholder":"Search options...","components.filterModal.noOptionsAvailable":"No options available","components.filterModal.noOptionsMatchSearch":"No options match your search","components.filterModal.reset":"Reset","components.filterModal.apply":"Apply","components.APY.tip":"These APYs are derived from the underlying protocols’ APIs and may differ in reality. Check respective protocols for their methodology.","components.creditSessionDetailedLiquidation.graph.noData":"No data","components.creditSessionDetailedLiquidation.graph.legend.point":"Current price","components.creditSessionDetailedLiquidation.graph.legend.area":"Liquidation Area","components.creditSessionDetailedLiquidation.graph.tip.hf":"Health Factor","components.creditSessionDetailedLiquidation.graph.tip.price":"Price","components.creditSessionDetailedLiquidation.table.noData":"No data","components.creditSessionDetailedLiquidation.table.seeGraph":"See graph","components.creditSessionDetailedLiquidation.table.asset":"Asset","components.creditSessionDetailedLiquidation.table.currentPrice":"Current price","components.creditSessionDetailedLiquidation.table.modelPrice":"Model price","components.apyParts.features.points":"Points","components.apyParts.features.incent":"Incent.","components.apyParts.supplyAPY":"Organic APY","components.apyParts.title":"APY type","components.apyParts.supplyAPY.tip":"Yield from lending funds","components.apyParts.tokenYield":"Intrinsic APY","components.apyParts.tokenYield.tip":"Yield from holding wstETH","components.apyParts.extraAPY":"{symbol} Incentive","components.apyParts.extraAPY.tip":"Calculated at the current rate","components.apyParts.totalAPY":"Overall APY","components.apyParts.points":"{symbol} Incentive","components.apyParts.points.condition.crossDeposit":"For cross-chain deposits made via Omni","components.openCopyButtons.copy":"Copy to clipboard","components.poolAssetsTable.asset":"Asset","components.poolAssetsTable.rate":"Effective rate","components.poolAssetsTable.limits":"Limits Usage","components.poolAssetsTable.usage":"{amount} of {total}","components.poolAssetsTable.head.name":"Credit Manager","components.poolAssetsTable.head.currentDebt":"Current Debt","components.poolAssetsTable.head.assets":"Asset LT","components.poolCreditManagersTable.assets":"{amount} assets","components.creditManagerInfo.title":"Assets and LT’s","components.creditManagerInfo.info.title":"Credit Managers","components.creditManagerInfo.info.copy.tip":"Copy Credit Manager address","components.creditManagerInfo.info.minDebt":"Min debt","components.creditManagerInfo.info.maxDebt":"Max debt","components.creditManagerInfo.info.liquidationFee":"Liquid. fee","components.creditManagerInfo.info.liquidationPremium":"Liquid. premium","components.creditManagerInfo.info.interestFee":"Interest fee","components.creditManagerInfo.info.debtLimit":"Debt limit","components.creditManagerInfo.info.maxEnabledTokens":"Max tokens","dialogs.oraclesAndLTInfo.filter.hide0Quota":"Hide 0-Quota","components.oraclesAndLTInfo.title":"Oracles and LTs","components.oraclesAndLTTable.head.token":"Token","components.oraclesAndLTTable.head.oracles":"Oracles","components.oraclesAndLTTable.head.lt":"LT","components.poolTable.pool":"Market","components.poolTable.market":"Market","components.poolTable.description.universal":"Universal","components.poolTable.supply":"Supply","components.poolTable.borrowed":"Borrowed","components.poolTable.supplyApy":"Supply APY","components.poolTable.supplyApy.tip":"Annual percentage yield that you earn for supplying capital. This number constantly changes as the utilization of the Markets goes up and down","components.poolTable.depositApy":"Deposit APY","components.poolTable.depositApy.tip":"Deposit APY breakdown: base rate, extra rewards, and points","components.poolTable.borrowApy":"Borrow APY","components.poolTable.utilizationApy":"Utilization APY","components.poolTable.borrowApy.tip":"On top of the utilization borrow APY, there is a borrow quota APY for different assets","components.poolTable.utilization":"Utilization","components.poolTable.collateral":"Collateral","components.poolTable.collateral.showAll":"Show All","components.poolTable.balance":"Your Balance","components.poolTable.balance.tip":`You don't earn token rewards, only organic yield. Please migrate liquidity by using "Migrate" flow above.`,"components.poolTable.emptyList":"No Pools found","components.poolTable.notFound.dashboard":"You currently have no open Market positions.","components.poolTable.notFound.list":"No Markets found","components.poolTable.notFound.description.dashboard":"Choose earn above.","components.poolTable.notFound.description.list":"Choose another chain or toggle Show All Markets","components.poolTable.externalApy.tooltipShort":"{value} APY boost when depositing via {name}","components.poolTable.line.rwa.tip":"This is RWA market.","components.rewardsTooltip.without.title":"Without Leverage","components.rewardsTooltip.without.extra":"Extra APY","components.rewardsTooltip.without.extra.tip":"Any deposit through Gearbox","components.rewardsTooltip.with.title":"With {leverage} Leverage","components.rewardsTooltip.with.borrowRate":"{symbol} borrow rate","components.rewardsTooltip.with.quotaRate":"Quota rate","components.rewardsTooltip.with.bonusAPY.title":"Target Bonuses Yield","components.rewardsTooltip.with.bonusAPY.tip":"Expected Bonuses APY is calculated by the Asset Issuer and represents the expected value to be paid out in points.","components.rewardsTooltip.with.extra":"+ Extra APR","components.rewardsTooltip.button":"Click to show rewards details","components.strategiesTable.head.name":"Strategy","components.strategiesTable.head.rewards":"Rewards","components.strategiesTable.head.leverage":"Max Leverage","components.strategiesTable.head.earn":"You Can Earn","components.strategiesTable.body.notFound":"No strategy found","components.strategiesTable.line.disabled":"This strategy is currently not available, cause of lack or quota or liquidity. Please contact us on Discord, and we’ll assist you.","components.strategiesTable.line.name.disabled":"This strategy is currently not available","components.strategiesTable.line.points.tip":"For debt nominated in {symbol}","components.strategiesTable.line.points.tipAny":"For debt","components.strategiesTable.line.0slippage":"0-slippage","components.strategiesTable.line.0slippage.tip":"Wrapping/unwrapping happens directly through smart-contracts, so {symbol} deposits and withdrawals don't incur slippage.","components.strategiesTable.line.rwa":"RWA","components.strategiesTable.line.rwa.tip":"This strategy is available on RWA market."};module.exports=e;
|
|
@@ -1,32 +1,36 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { cva as
|
|
3
|
-
import * as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
1
|
+
import { jsxs as l, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { cva as I } from "class-variance-authority";
|
|
3
|
+
import * as n from "react";
|
|
4
|
+
import { createPortal as ne } from "react-dom";
|
|
5
|
+
import { Checkbox as se } from "../checkbox/checkbox.js";
|
|
6
|
+
import "../checkbox/checkbox-labeled.js";
|
|
7
|
+
import { CurrencyButton as ae } from "../currency-button/currency-button.js";
|
|
8
|
+
import { faXmark as oe } from "@fortawesome/free-solid-svg-icons";
|
|
9
|
+
import { FaIcon as ie } from "../icons/fa-icon.js";
|
|
10
|
+
import { useIntlTyped as le, FormattedMessageTyped as B } from "../typed-intl/index.js";
|
|
11
|
+
import { useIsMobile as ce, useIsTablet as de, useIsDesktop as ue } from "../../hooks/use-media-query.js";
|
|
12
|
+
import { smartNumberInputTestIds as w } from "../../test-ids/smart-number-input.js";
|
|
13
|
+
import { bnToInputView as me } from "../../utils/bn-to-input-view.js";
|
|
10
14
|
import "@gearbox-protocol/sdk";
|
|
11
|
-
import { parseInputToBN as
|
|
12
|
-
import { cn as
|
|
15
|
+
import { parseInputToBN as fe } from "../../utils/parse-input-to-bn.js";
|
|
16
|
+
import { cn as v } from "../../utils/cn.js";
|
|
13
17
|
import "sonner";
|
|
14
18
|
import "@gearbox-protocol/sdk/common-utils";
|
|
15
19
|
import "luxon";
|
|
16
20
|
import "../../utils/z-index.js";
|
|
17
|
-
import { BalanceIndicator as
|
|
18
|
-
const
|
|
21
|
+
import { BalanceIndicator as pe } from "./balance-indicator.js";
|
|
22
|
+
const he = I(
|
|
19
23
|
"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
24
|
{
|
|
21
25
|
variants: {
|
|
22
26
|
size: {
|
|
23
|
-
sm: "px-3 py-[7px] h-[60px] rounded-[8px]",
|
|
24
|
-
md: "pl-4 pr-3 py-[10px] h-[82px] rounded-lg"
|
|
27
|
+
sm: "px-3 py-[7px] min-h-[60px] rounded-[8px]",
|
|
28
|
+
md: "pl-4 pr-3 py-[10px] min-h-[82px] rounded-lg"
|
|
25
29
|
}
|
|
26
30
|
},
|
|
27
31
|
defaultVariants: { size: "md" }
|
|
28
32
|
}
|
|
29
|
-
),
|
|
33
|
+
), ge = I("font-medium text-foreground", {
|
|
30
34
|
variants: {
|
|
31
35
|
size: {
|
|
32
36
|
sm: "text-xs",
|
|
@@ -34,7 +38,7 @@ const ae = b(
|
|
|
34
38
|
}
|
|
35
39
|
},
|
|
36
40
|
defaultVariants: { size: "md" }
|
|
37
|
-
}),
|
|
41
|
+
}), xe = I(
|
|
38
42
|
"w-full p-0 bg-transparent border-none outline-none text-foreground placeholder:text-secondary-foreground focus:outline-none",
|
|
39
43
|
{
|
|
40
44
|
variants: {
|
|
@@ -45,103 +49,137 @@ const ae = b(
|
|
|
45
49
|
},
|
|
46
50
|
defaultVariants: { size: "md" }
|
|
47
51
|
}
|
|
48
|
-
)
|
|
52
|
+
);
|
|
53
|
+
function be(p, s) {
|
|
54
|
+
const u = parseFloat(p.replace(",", ".") || "0");
|
|
55
|
+
if (!Number.isFinite(u) || u === 0) return "$0";
|
|
56
|
+
const a = u * s, g = Math.abs(a) < 100;
|
|
57
|
+
try {
|
|
58
|
+
return new Intl.NumberFormat("en-US", {
|
|
59
|
+
style: "currency",
|
|
60
|
+
currency: "USD",
|
|
61
|
+
minimumFractionDigits: g ? 2 : 0,
|
|
62
|
+
maximumFractionDigits: g ? 2 : 0
|
|
63
|
+
}).format(a);
|
|
64
|
+
} catch {
|
|
65
|
+
return "$0";
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
const we = n.forwardRef(
|
|
49
69
|
({
|
|
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
|
-
symbolMaxLength:
|
|
63
|
-
tokenOptions:
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
const e = s && f && s > f ? f : s || 0n, r = ee(e, w);
|
|
76
|
-
o(e, r);
|
|
77
|
-
}
|
|
78
|
-
}, [X, N] = c.useState(!1), $ = () => {
|
|
79
|
-
N(!0), E?.();
|
|
70
|
+
amount: p,
|
|
71
|
+
token: s,
|
|
72
|
+
label: u,
|
|
73
|
+
maxAmount: a,
|
|
74
|
+
maxAmountLimit: h,
|
|
75
|
+
maxButtonLabel: g,
|
|
76
|
+
chainId: T,
|
|
77
|
+
network: V,
|
|
78
|
+
maxButton: S = !0,
|
|
79
|
+
disabled: c = !1,
|
|
80
|
+
active: E = !1,
|
|
81
|
+
size: R = "md",
|
|
82
|
+
symbolMaxLength: D,
|
|
83
|
+
tokenOptions: y,
|
|
84
|
+
multiSelectMode: j = !1,
|
|
85
|
+
onSetAmount: m,
|
|
86
|
+
onShowSelectDialog: C,
|
|
87
|
+
onRemove: z,
|
|
88
|
+
onFocus: $,
|
|
89
|
+
onBlur: U,
|
|
90
|
+
usdPrice: k
|
|
91
|
+
}, W) => {
|
|
92
|
+
const { formatMessage: O } = le(), P = n.useId(), L = s?.decimals ?? 18, X = (e) => {
|
|
93
|
+
const r = e.target.value, [o, i] = fe(r, L);
|
|
94
|
+
o === null || i === null || m && m(o, i);
|
|
80
95
|
}, q = () => {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
96
|
+
if (m) {
|
|
97
|
+
const e = a && h && a > h ? h : a || 0n, r = me(e, L);
|
|
98
|
+
m(e, r);
|
|
99
|
+
}
|
|
100
|
+
}, [G, M] = n.useState(!1), H = () => {
|
|
101
|
+
M(!0), $?.();
|
|
102
|
+
}, J = () => {
|
|
103
|
+
M(!1), U?.();
|
|
104
|
+
}, f = R ?? "md", K = ce(), Q = de(), Y = ue(), Z = D ?? (K ? 20 : Q ? 30 : Y ? 22 : 30), [d, N] = n.useState(!1), x = n.useRef(null), F = n.useRef(null), [_, A] = n.useState({});
|
|
105
|
+
n.useLayoutEffect(() => {
|
|
106
|
+
if (!d || !x.current) return;
|
|
107
|
+
const e = () => {
|
|
108
|
+
const r = x.current?.getBoundingClientRect();
|
|
109
|
+
r && A({
|
|
110
|
+
position: "fixed",
|
|
111
|
+
top: r.bottom + 4,
|
|
112
|
+
right: window.innerWidth - r.right,
|
|
113
|
+
minWidth: r.width,
|
|
114
|
+
zIndex: 9999
|
|
115
|
+
});
|
|
116
|
+
};
|
|
117
|
+
return e(), window.addEventListener("scroll", e, !0), window.addEventListener("resize", e), () => {
|
|
118
|
+
window.removeEventListener("scroll", e, !0), window.removeEventListener("resize", e);
|
|
119
|
+
};
|
|
120
|
+
}, [d]), n.useEffect(() => {
|
|
121
|
+
if (!d) return;
|
|
85
122
|
const e = (r) => {
|
|
86
|
-
|
|
123
|
+
const o = r.target, i = x.current?.contains(o), re = F.current?.contains(o);
|
|
124
|
+
!i && !re && N(!1);
|
|
87
125
|
};
|
|
88
126
|
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
89
|
-
}, [
|
|
90
|
-
const
|
|
91
|
-
return /* @__PURE__ */
|
|
127
|
+
}, [d]);
|
|
128
|
+
const b = !!(y && y.length > 0), ee = !c && b ? () => N((e) => !e) : C, te = !!(s || C || b);
|
|
129
|
+
return /* @__PURE__ */ l(
|
|
92
130
|
"div",
|
|
93
131
|
{
|
|
94
|
-
ref:
|
|
95
|
-
className:
|
|
96
|
-
"data-testid":
|
|
97
|
-
"data-active":
|
|
98
|
-
"data-disabled":
|
|
132
|
+
ref: W,
|
|
133
|
+
className: he({ size: f }),
|
|
134
|
+
"data-testid": w.root,
|
|
135
|
+
"data-active": G,
|
|
136
|
+
"data-disabled": c,
|
|
99
137
|
children: [
|
|
100
|
-
|
|
138
|
+
z && /* @__PURE__ */ t(
|
|
101
139
|
"div",
|
|
102
140
|
{
|
|
103
141
|
className: "absolute top-0 right-0 flex h-5 w-5 translate-x-1/2 -translate-y-1/2 items-center justify-center",
|
|
104
|
-
"data-testid":
|
|
142
|
+
"data-testid": w.close,
|
|
105
143
|
children: /* @__PURE__ */ t(
|
|
106
144
|
"button",
|
|
107
145
|
{
|
|
108
146
|
type: "button",
|
|
109
|
-
onClick:
|
|
147
|
+
onClick: z,
|
|
110
148
|
className: "flex h-5 w-5 items-center justify-center rounded-full bg-muted hover:bg-muted/80 text-muted-foreground",
|
|
111
|
-
children: /* @__PURE__ */ t(
|
|
149
|
+
children: /* @__PURE__ */ t(ie, { icon: oe, className: "size-3" })
|
|
112
150
|
}
|
|
113
151
|
)
|
|
114
152
|
}
|
|
115
153
|
),
|
|
116
|
-
/* @__PURE__ */
|
|
154
|
+
/* @__PURE__ */ l("div", { className: "mb-2 flex justify-between text-sm leading-[120%]", children: [
|
|
117
155
|
/* @__PURE__ */ t(
|
|
118
156
|
"span",
|
|
119
157
|
{
|
|
120
|
-
className:
|
|
121
|
-
|
|
158
|
+
className: v(
|
|
159
|
+
ge({ size: f }),
|
|
122
160
|
"grow shrink-0 basis-0"
|
|
123
161
|
),
|
|
124
|
-
"data-testid":
|
|
125
|
-
children:
|
|
162
|
+
"data-testid": w.label,
|
|
163
|
+
children: u ?? /* @__PURE__ */ t(B, { messageId: "components.smartNumberInput.amountLabel" })
|
|
126
164
|
}
|
|
127
165
|
),
|
|
128
|
-
|
|
129
|
-
|
|
166
|
+
a !== void 0 && s && /* @__PURE__ */ t(
|
|
167
|
+
pe,
|
|
130
168
|
{
|
|
131
|
-
title:
|
|
132
|
-
token:
|
|
133
|
-
maxAmount:
|
|
134
|
-
size:
|
|
135
|
-
disabled:
|
|
136
|
-
maxButton:
|
|
137
|
-
onMaxButtonClick:
|
|
169
|
+
title: g,
|
|
170
|
+
token: s,
|
|
171
|
+
maxAmount: a,
|
|
172
|
+
size: f,
|
|
173
|
+
disabled: c,
|
|
174
|
+
maxButton: S,
|
|
175
|
+
onMaxButtonClick: q
|
|
138
176
|
}
|
|
139
177
|
)
|
|
140
178
|
] }),
|
|
141
|
-
/* @__PURE__ */
|
|
179
|
+
/* @__PURE__ */ l(
|
|
142
180
|
"div",
|
|
143
181
|
{
|
|
144
|
-
className:
|
|
182
|
+
className: v(
|
|
145
183
|
"flex w-full max-w-full shrink-0 basis-full items-center"
|
|
146
184
|
),
|
|
147
185
|
children: [
|
|
@@ -155,61 +193,108 @@ const ae = b(
|
|
|
155
193
|
spellCheck: "false",
|
|
156
194
|
pattern: "^[0-9]*[.,]?[0-9]*$",
|
|
157
195
|
placeholder: "0",
|
|
158
|
-
value:
|
|
159
|
-
onChange:
|
|
160
|
-
onFocus:
|
|
161
|
-
onBlur:
|
|
162
|
-
disabled:
|
|
163
|
-
className:
|
|
164
|
-
|
|
165
|
-
|
|
196
|
+
value: p,
|
|
197
|
+
onChange: X,
|
|
198
|
+
onFocus: H,
|
|
199
|
+
onBlur: J,
|
|
200
|
+
disabled: c || !m,
|
|
201
|
+
className: v(
|
|
202
|
+
xe({ size: f }),
|
|
203
|
+
c && "cursor-not-allowed"
|
|
166
204
|
),
|
|
167
|
-
"data-testid":
|
|
205
|
+
"data-testid": w.input,
|
|
168
206
|
minLength: 1,
|
|
169
207
|
maxLength: 79,
|
|
170
|
-
title:
|
|
208
|
+
title: O({
|
|
209
|
+
messageId: "components.smartNumberInput.inputTitle"
|
|
210
|
+
})
|
|
171
211
|
}
|
|
172
212
|
) }),
|
|
173
|
-
|
|
213
|
+
te ? /* @__PURE__ */ l("div", { ref: x, className: "shrink-0", children: [
|
|
174
214
|
/* @__PURE__ */ t(
|
|
175
|
-
|
|
215
|
+
ae,
|
|
176
216
|
{
|
|
177
|
-
active:
|
|
178
|
-
size:
|
|
179
|
-
disabled:
|
|
180
|
-
token:
|
|
181
|
-
showSelectDialog:
|
|
182
|
-
chainId:
|
|
183
|
-
network:
|
|
184
|
-
maxLength:
|
|
185
|
-
children:
|
|
217
|
+
active: b ? d : E,
|
|
218
|
+
size: f,
|
|
219
|
+
disabled: c,
|
|
220
|
+
token: s,
|
|
221
|
+
showSelectDialog: ee,
|
|
222
|
+
chainId: T,
|
|
223
|
+
network: V,
|
|
224
|
+
maxLength: Z,
|
|
225
|
+
children: s?.symbol ?? /* @__PURE__ */ t(B, { messageId: "components.smartNumberInput.selectToken" })
|
|
186
226
|
}
|
|
187
227
|
),
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
228
|
+
b && d && ne(
|
|
229
|
+
/* @__PURE__ */ t(
|
|
230
|
+
"div",
|
|
231
|
+
{
|
|
232
|
+
ref: F,
|
|
233
|
+
style: _,
|
|
234
|
+
className: "overflow-hidden rounded-lg border border-gray-30 bg-gray-20 shadow-lg",
|
|
235
|
+
children: y?.map((e, r) => {
|
|
236
|
+
const o = `${P}-${r}`, i = "flex w-full min-w-0 items-center gap-2 px-3 py-2 text-sm text-foreground hover:bg-gray-30";
|
|
237
|
+
return j ? /* @__PURE__ */ l(
|
|
238
|
+
"div",
|
|
239
|
+
{
|
|
240
|
+
className: i,
|
|
241
|
+
children: [
|
|
242
|
+
/* @__PURE__ */ t(
|
|
243
|
+
se,
|
|
244
|
+
{
|
|
245
|
+
id: o,
|
|
246
|
+
checked: !!e.checked,
|
|
247
|
+
color: "secondary",
|
|
248
|
+
size: "md",
|
|
249
|
+
className: "shrink-0",
|
|
250
|
+
onCheckedChange: () => e.onSelect()
|
|
251
|
+
}
|
|
252
|
+
),
|
|
253
|
+
/* @__PURE__ */ l(
|
|
254
|
+
"label",
|
|
255
|
+
{
|
|
256
|
+
htmlFor: o,
|
|
257
|
+
className: "flex min-w-0 flex-1 cursor-pointer items-center gap-2 text-left",
|
|
258
|
+
children: [
|
|
259
|
+
e.icon ? /* @__PURE__ */ t("span", { className: "inline-flex shrink-0 items-center", children: e.icon }) : null,
|
|
260
|
+
/* @__PURE__ */ t("span", { className: "truncate", children: e.label })
|
|
261
|
+
]
|
|
262
|
+
}
|
|
263
|
+
)
|
|
264
|
+
]
|
|
265
|
+
},
|
|
266
|
+
r
|
|
267
|
+
) : /* @__PURE__ */ l(
|
|
268
|
+
"button",
|
|
269
|
+
{
|
|
270
|
+
type: "button",
|
|
271
|
+
onClick: () => {
|
|
272
|
+
e.onSelect(), N(!1);
|
|
273
|
+
},
|
|
274
|
+
className: v(i, "text-left"),
|
|
275
|
+
children: [
|
|
276
|
+
e.icon ? /* @__PURE__ */ t("span", { className: "inline-flex shrink-0 items-center", children: e.icon }) : null,
|
|
277
|
+
/* @__PURE__ */ t("span", { className: "truncate", children: e.label })
|
|
278
|
+
]
|
|
279
|
+
},
|
|
280
|
+
r
|
|
281
|
+
);
|
|
282
|
+
})
|
|
283
|
+
}
|
|
284
|
+
),
|
|
285
|
+
document.body
|
|
286
|
+
)
|
|
203
287
|
] }) : null
|
|
204
288
|
]
|
|
205
289
|
}
|
|
206
|
-
)
|
|
290
|
+
),
|
|
291
|
+
k !== void 0 && /* @__PURE__ */ t("div", { className: "mt-1 text-xs leading-[130%] text-secondary-foreground", children: be(p, k) })
|
|
207
292
|
]
|
|
208
293
|
}
|
|
209
294
|
);
|
|
210
295
|
}
|
|
211
296
|
);
|
|
212
|
-
|
|
297
|
+
we.displayName = "SmartNumberInput";
|
|
213
298
|
export {
|
|
214
|
-
|
|
299
|
+
we as SmartNumberInput
|
|
215
300
|
};
|
|
@@ -20,8 +20,10 @@ const e = {
|
|
|
20
20
|
"components.loading.loadingPercent": "Loading {percent}%",
|
|
21
21
|
"components.loading.wait": "Please wait...",
|
|
22
22
|
"components.smartNumberInput.balance": "Balance",
|
|
23
|
+
"components.smartNumberInput.amountLabel": "Amount",
|
|
23
24
|
"components.smartNumberInput.inputTitle": "Token Amount",
|
|
24
25
|
"components.smartNumberInput.confirm.input": "Input",
|
|
26
|
+
"components.smartNumberInput.selectToken": "Select token",
|
|
25
27
|
"components.tipWindow.title": "Tip",
|
|
26
28
|
"components.healthFactor.low": "Extremely low! This HF may not cover possible oracle deviations.",
|
|
27
29
|
"components.headCell": "Sort by {value}",
|