@gearbox-protocol/ui-kit 3.14.0-next.5 → 3.14.0-next.6
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/esm/components/health-factor/health-factor.js +3 -3
- package/dist/esm/components/smart-number-input/smart-number-input.js +156 -123
- package/dist/globals.css +1 -1
- package/dist/types/components/help-tip/help-tip.d.ts +2 -2
- package/dist/types/components/smart-number-input/smart-number-input.d.ts +19 -0
- package/dist/types/components/tip-card/tip-card.d.ts +1 -1
- 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 e=require("react/jsx-runtime"),q=require("class-variance-authority"),de=require("react"),me=require("react-dom"),pe=require("../checkbox/checkbox.cjs");require("../checkbox/checkbox-labeled.cjs");const fe=require("../currency-button/currency-button.cjs"),he=require("../health-factor/health-factor.cjs"),xe=require("@fortawesome/free-solid-svg-icons"),ge=require("../icons/fa-icon.cjs"),be=require("../slider/slider.cjs");require("../slider/slider-context.cjs");const I=require("../typed-intl/index.cjs"),j=require("../../hooks/use-media-query.cjs"),v=require("../../test-ids/smart-number-input.cjs"),ve=require("../../utils/bn-to-input-view.cjs");require("@gearbox-protocol/sdk");const ye=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 we=require("./balance-indicator.cjs");function Ne(n){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const o in n)if(o!=="default"){const a=Object.getOwnPropertyDescriptor(n,o);Object.defineProperty(r,o,a.get?a:{enumerable:!0,get:()=>n[o]})}}return r.default=n,Object.freeze(r)}const c=Ne(de),Ie=q.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"}}),je=q.cva("font-medium text-foreground",{variants:{size:{sm:"text-xs",md:"text-sm"}},defaultVariants:{size:"md"}}),ke=q.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 k(n){return Math.round(n*100)}function qe(n){return n/100}function Me(n,r){const o=parseFloat(n.replace(",",".")||"0");if(!Number.isFinite(o)||o===0)return"$0";const a=o*r,x=Math.abs(a)<100;try{return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:x?2:0,maximumFractionDigits:x?2:0}).format(a)}catch{return"$0"}}const S=c.forwardRef(({amount:n,token:r,label:o,maxAmount:a,maxAmountLimit:h,maxButtonLabel:x,chainId:L,network:B,maxButton:V=!0,disabled:d=!1,active:D=!1,size:R="md",symbolMaxLength:E,tokenOptions:w,multiSelectMode:O=!1,onSetAmount:p,onShowSelectDialog:M,onRemove:_,onFocus:P,onBlur:$,usdPrice:C,hfSlider:l},H)=>{const{formatMessage:U}=I.useIntlTyped(),W=c.useId(),T=r?.decimals??18,Q=t=>{const s=t.target.value,[i,u]=ye.parseInputToBN(s,T);i===null||u===null||p&&p(i,u)},X=()=>{if(p){const t=a&&h&&a>h?h:a||0n,s=ve.bnToInputView(t,T);p(t,s)}},[G,z]=c.useState(!1),J=()=>{z(!0),P?.()},K=()=>{z(!1),$?.()},Y=j.useIsMobile(),Z=l?.min??1,A=l?.max??3,ee=l?.step??.01,te=Math.max(1,Math.round(1/ee)),f=R??"md",ne=Y,se=j.useIsTablet(),re=j.useIsDesktop(),ae=E??(ne?20:se?30:re?22:30),[m,N]=c.useState(!1),g=c.useRef(null),F=c.useRef(null),[oe,ce]=c.useState({});c.useLayoutEffect(()=>{if(!m||!g.current)return;const t=()=>{const s=g.current?.getBoundingClientRect();s&&ce({position:"fixed",top:s.bottom+4,right:window.innerWidth-s.right,minWidth:s.width,zIndex:9999})};return t(),window.addEventListener("scroll",t,!0),window.addEventListener("resize",t),()=>{window.removeEventListener("scroll",t,!0),window.removeEventListener("resize",t)}},[m]),c.useEffect(()=>{if(!m)return;const t=s=>{const i=s.target,u=g.current?.contains(i),ue=F.current?.contains(i);!u&&!ue&&N(!1)};return document.addEventListener("mousedown",t),()=>document.removeEventListener("mousedown",t)},[m]);const b=!!(w&&w.length>0),ie=!d&&b?()=>N(t=>!t):M,le=!!(r||M||b);return e.jsxs("div",{ref:H,className:Ie({size:f}),"data-testid":v.smartNumberInputTestIds.root,"data-active":G,"data-disabled":d,children:[_&&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":v.smartNumberInputTestIds.close,children:e.jsx("button",{type:"button",onClick:_,className:"flex h-5 w-5 items-center justify-center rounded-full bg-muted hover:bg-muted/80 text-muted-foreground",children:e.jsx(ge.FaIcon,{icon:xe.faXmark,className:"size-3"})})}),e.jsxs("div",{className:"mb-2 flex justify-between text-sm leading-[120%]",children:[e.jsx("span",{className:y.cn(je({size:f}),"grow shrink-0 basis-0"),"data-testid":v.smartNumberInputTestIds.label,children:o??e.jsx(I.FormattedMessageTyped,{messageId:"components.smartNumberInput.amountLabel"})}),l!==void 0?e.jsxs("div",{className:"ml-auto flex w-1/2 min-w-0 items-center gap-1",children:[e.jsx("span",{className:"shrink-0 text-xs text-secondary-foreground",children:"HF"}),e.jsx("div",{className:"min-w-0 flex-1 [&>div]:px-0 [&>div]:pb-0",children:e.jsx(be.Slider,{from:k(Z),to:k(A),value:k(l.value),precision:te,markerStep:0,epsilon:0,onChangeValue:t=>l.onChange(qe(t))})}),e.jsx(he.HealthFactor,{value:Math.round(l.value*1e4),debt:1n,decimals:2,className:"shrink-0 text-xs tabular-nums"})]}):a!==void 0&&r&&e.jsx(we.BalanceIndicator,{title:x,token:r,maxAmount:a,size:f,disabled:d,maxButton:V,onMaxButtonClick:X})]}),e.jsxs("div",{className:y.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:n,onChange:Q,onFocus:J,onBlur:K,disabled:d||!p,className:y.cn(ke({size:f}),d&&"cursor-not-allowed"),"data-testid":v.smartNumberInputTestIds.input,minLength:1,maxLength:79,title:U({messageId:"components.smartNumberInput.inputTitle"})})}),le?e.jsxs("div",{ref:g,className:"shrink-0",children:[e.jsx(fe.CurrencyButton,{active:b?m:D,size:f,disabled:d,token:r,showSelectDialog:ie,chainId:L,network:B,maxLength:ae,children:r?.symbol??e.jsx(I.FormattedMessageTyped,{messageId:"components.smartNumberInput.selectToken"})}),b&&m&&me.createPortal(e.jsx("div",{ref:F,style:oe,className:"overflow-hidden rounded-lg border border-gray-30 bg-gray-20 shadow-lg",children:w?.map((t,s)=>{const i=`${W}-${s}`,u="flex w-full min-w-0 items-center gap-2 px-3 py-2 text-sm text-foreground hover:bg-gray-30";return O?e.jsxs("div",{className:u,children:[e.jsx(pe.Checkbox,{id:i,checked:!!t.checked,color:"secondary",size:"md",className:"shrink-0",onCheckedChange:()=>t.onSelect()}),e.jsxs("label",{htmlFor:i,className:"flex min-w-0 flex-1 cursor-pointer items-center gap-2 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})]})]},s):e.jsxs("button",{type:"button",onClick:()=>{t.onSelect(),N(!1)},className:y.cn(u,"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})]},s)})}),document.body)]}):null]}),C!==void 0&&e.jsx("div",{className:"mt-1 text-xs leading-[130%] text-secondary-foreground",children:Me(n,C)})]})});S.displayName="SmartNumberInput";exports.SmartNumberInput=S;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsxs as f, jsx as c } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { formatPercentage as p, PERCENTAGE_FACTOR as v } from "@gearbox-protocol/sdk";
|
|
3
3
|
import { cva as x } from "class-variance-authority";
|
|
4
4
|
import "react";
|
|
5
5
|
import { cn as C } from "../../utils/cn.js";
|
|
@@ -10,7 +10,7 @@ import "../../utils/z-index.js";
|
|
|
10
10
|
import { StatusBars as F } from "../status-elements/status-elements.js";
|
|
11
11
|
const g = 15e3, A = 11e3, H = 10500, N = (t) => {
|
|
12
12
|
if (t)
|
|
13
|
-
return t >= g ? "good" : t > A ? "medium" : t > H ? "bad" : t >
|
|
13
|
+
return t >= g ? "good" : t > A ? "medium" : t > H ? "bad" : t > v ? "critical" : "liquidation";
|
|
14
14
|
}, b = x(
|
|
15
15
|
"inline-flex items-center font-medium [text-decoration:inherit]",
|
|
16
16
|
{
|
|
@@ -38,7 +38,7 @@ function G({
|
|
|
38
38
|
const n = e !== void 0 && e === 0n, r = !n && i === "color" ? o === void 0 ? N(t) : o : void 0, s = r === void 0 ? void 0 : r === null ? "unset" : r, d = () => {
|
|
39
39
|
if (n) return "N/A";
|
|
40
40
|
const l = Number(t);
|
|
41
|
-
return
|
|
41
|
+
return p(l, a);
|
|
42
42
|
};
|
|
43
43
|
return /* @__PURE__ */ f(
|
|
44
44
|
"span",
|
|
@@ -1,25 +1,28 @@
|
|
|
1
1
|
import { jsxs as l, jsx as t } from "react/jsx-runtime";
|
|
2
|
-
import { cva as
|
|
3
|
-
import * as
|
|
4
|
-
import { createPortal as
|
|
5
|
-
import { Checkbox as
|
|
2
|
+
import { cva as k } from "class-variance-authority";
|
|
3
|
+
import * as r from "react";
|
|
4
|
+
import { createPortal as de } from "react-dom";
|
|
5
|
+
import { Checkbox as ue } from "../checkbox/checkbox.js";
|
|
6
6
|
import "../checkbox/checkbox-labeled.js";
|
|
7
|
-
import { CurrencyButton as
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
7
|
+
import { CurrencyButton as me } from "../currency-button/currency-button.js";
|
|
8
|
+
import { HealthFactor as fe } from "../health-factor/health-factor.js";
|
|
9
|
+
import { faXmark as pe } from "@fortawesome/free-solid-svg-icons";
|
|
10
|
+
import { FaIcon as he } from "../icons/fa-icon.js";
|
|
11
|
+
import { Slider as ge } from "../slider/slider.js";
|
|
12
|
+
import "../slider/slider-context.js";
|
|
13
|
+
import { useIntlTyped as xe, FormattedMessageTyped as B } from "../typed-intl/index.js";
|
|
14
|
+
import { useIsMobile as be, useIsTablet as ve, useIsDesktop as we } from "../../hooks/use-media-query.js";
|
|
12
15
|
import { smartNumberInputTestIds as w } from "../../test-ids/smart-number-input.js";
|
|
13
|
-
import { bnToInputView as
|
|
16
|
+
import { bnToInputView as ye } from "../../utils/bn-to-input-view.js";
|
|
14
17
|
import "@gearbox-protocol/sdk";
|
|
15
|
-
import { parseInputToBN as
|
|
16
|
-
import { cn as
|
|
18
|
+
import { parseInputToBN as Ne } from "../../utils/parse-input-to-bn.js";
|
|
19
|
+
import { cn as y } from "../../utils/cn.js";
|
|
17
20
|
import "sonner";
|
|
18
21
|
import "@gearbox-protocol/sdk/common-utils";
|
|
19
22
|
import "luxon";
|
|
20
23
|
import "../../utils/z-index.js";
|
|
21
|
-
import { BalanceIndicator as
|
|
22
|
-
const
|
|
24
|
+
import { BalanceIndicator as Ie } from "./balance-indicator.js";
|
|
25
|
+
const Ce = k(
|
|
23
26
|
"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",
|
|
24
27
|
{
|
|
25
28
|
variants: {
|
|
@@ -30,7 +33,7 @@ const he = I(
|
|
|
30
33
|
},
|
|
31
34
|
defaultVariants: { size: "md" }
|
|
32
35
|
}
|
|
33
|
-
),
|
|
36
|
+
), ke = k("font-medium text-foreground", {
|
|
34
37
|
variants: {
|
|
35
38
|
size: {
|
|
36
39
|
sm: "text-xs",
|
|
@@ -38,7 +41,7 @@ const he = I(
|
|
|
38
41
|
}
|
|
39
42
|
},
|
|
40
43
|
defaultVariants: { size: "md" }
|
|
41
|
-
}),
|
|
44
|
+
}), Me = k(
|
|
42
45
|
"w-full p-0 bg-transparent border-none outline-none text-foreground placeholder:text-secondary-foreground focus:outline-none",
|
|
43
46
|
{
|
|
44
47
|
variants: {
|
|
@@ -50,90 +53,97 @@ const he = I(
|
|
|
50
53
|
defaultVariants: { size: "md" }
|
|
51
54
|
}
|
|
52
55
|
);
|
|
53
|
-
function
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
56
|
+
function C(s) {
|
|
57
|
+
return Math.round(s * 100);
|
|
58
|
+
}
|
|
59
|
+
function ze(s) {
|
|
60
|
+
return s / 100;
|
|
61
|
+
}
|
|
62
|
+
function Fe(s, a) {
|
|
63
|
+
const f = parseFloat(s.replace(",", ".") || "0");
|
|
64
|
+
if (!Number.isFinite(f) || f === 0) return "$0";
|
|
65
|
+
const o = f * a, x = Math.abs(o) < 100;
|
|
57
66
|
try {
|
|
58
67
|
return new Intl.NumberFormat("en-US", {
|
|
59
68
|
style: "currency",
|
|
60
69
|
currency: "USD",
|
|
61
|
-
minimumFractionDigits:
|
|
62
|
-
maximumFractionDigits:
|
|
63
|
-
}).format(
|
|
70
|
+
minimumFractionDigits: x ? 2 : 0,
|
|
71
|
+
maximumFractionDigits: x ? 2 : 0
|
|
72
|
+
}).format(o);
|
|
64
73
|
} catch {
|
|
65
74
|
return "$0";
|
|
66
75
|
}
|
|
67
76
|
}
|
|
68
|
-
const
|
|
77
|
+
const Le = r.forwardRef(
|
|
69
78
|
({
|
|
70
|
-
amount:
|
|
71
|
-
token:
|
|
72
|
-
label:
|
|
73
|
-
maxAmount:
|
|
74
|
-
maxAmountLimit:
|
|
75
|
-
maxButtonLabel:
|
|
76
|
-
chainId:
|
|
77
|
-
network:
|
|
78
|
-
maxButton:
|
|
79
|
-
disabled:
|
|
80
|
-
active:
|
|
81
|
-
size:
|
|
82
|
-
symbolMaxLength:
|
|
83
|
-
tokenOptions:
|
|
84
|
-
multiSelectMode:
|
|
85
|
-
onSetAmount:
|
|
86
|
-
onShowSelectDialog:
|
|
79
|
+
amount: s,
|
|
80
|
+
token: a,
|
|
81
|
+
label: f,
|
|
82
|
+
maxAmount: o,
|
|
83
|
+
maxAmountLimit: g,
|
|
84
|
+
maxButtonLabel: x,
|
|
85
|
+
chainId: S,
|
|
86
|
+
network: E,
|
|
87
|
+
maxButton: R = !0,
|
|
88
|
+
disabled: u = !1,
|
|
89
|
+
active: D = !1,
|
|
90
|
+
size: j = "md",
|
|
91
|
+
symbolMaxLength: $,
|
|
92
|
+
tokenOptions: N,
|
|
93
|
+
multiSelectMode: H = !1,
|
|
94
|
+
onSetAmount: p,
|
|
95
|
+
onShowSelectDialog: M,
|
|
87
96
|
onRemove: z,
|
|
88
|
-
onFocus:
|
|
89
|
-
onBlur:
|
|
90
|
-
usdPrice:
|
|
97
|
+
onFocus: U,
|
|
98
|
+
onBlur: P,
|
|
99
|
+
usdPrice: F,
|
|
100
|
+
hfSlider: c
|
|
91
101
|
}, W) => {
|
|
92
|
-
const { formatMessage: O } =
|
|
93
|
-
const
|
|
94
|
-
|
|
95
|
-
},
|
|
96
|
-
if (
|
|
97
|
-
const e =
|
|
98
|
-
|
|
102
|
+
const { formatMessage: O } = xe(), X = r.useId(), L = a?.decimals ?? 18, q = (e) => {
|
|
103
|
+
const n = e.target.value, [i, d] = Ne(n, L);
|
|
104
|
+
i === null || d === null || p && p(i, d);
|
|
105
|
+
}, G = () => {
|
|
106
|
+
if (p) {
|
|
107
|
+
const e = o && g && o > g ? g : o || 0n, n = ye(e, L);
|
|
108
|
+
p(e, n);
|
|
99
109
|
}
|
|
100
|
-
}, [
|
|
101
|
-
|
|
102
|
-
},
|
|
103
|
-
|
|
104
|
-
},
|
|
105
|
-
|
|
106
|
-
if (!
|
|
110
|
+
}, [J, T] = r.useState(!1), K = () => {
|
|
111
|
+
T(!0), U?.();
|
|
112
|
+
}, Q = () => {
|
|
113
|
+
T(!1), P?.();
|
|
114
|
+
}, Y = be(), Z = c?.min ?? 1, _ = c?.max ?? 3, A = c?.step ?? 0.01, ee = Math.max(1, Math.round(1 / A)), h = j ?? "md", te = Y, ne = ve(), re = we(), se = $ ?? (te ? 20 : ne ? 30 : re ? 22 : 30), [m, I] = r.useState(!1), b = r.useRef(null), V = r.useRef(null), [ae, oe] = r.useState({});
|
|
115
|
+
r.useLayoutEffect(() => {
|
|
116
|
+
if (!m || !b.current) return;
|
|
107
117
|
const e = () => {
|
|
108
|
-
const
|
|
109
|
-
|
|
118
|
+
const n = b.current?.getBoundingClientRect();
|
|
119
|
+
n && oe({
|
|
110
120
|
position: "fixed",
|
|
111
|
-
top:
|
|
112
|
-
right: window.innerWidth -
|
|
113
|
-
minWidth:
|
|
121
|
+
top: n.bottom + 4,
|
|
122
|
+
right: window.innerWidth - n.right,
|
|
123
|
+
minWidth: n.width,
|
|
114
124
|
zIndex: 9999
|
|
115
125
|
});
|
|
116
126
|
};
|
|
117
127
|
return e(), window.addEventListener("scroll", e, !0), window.addEventListener("resize", e), () => {
|
|
118
128
|
window.removeEventListener("scroll", e, !0), window.removeEventListener("resize", e);
|
|
119
129
|
};
|
|
120
|
-
}, [
|
|
121
|
-
if (!
|
|
122
|
-
const e = (
|
|
123
|
-
const
|
|
124
|
-
!
|
|
130
|
+
}, [m]), r.useEffect(() => {
|
|
131
|
+
if (!m) return;
|
|
132
|
+
const e = (n) => {
|
|
133
|
+
const i = n.target, d = b.current?.contains(i), ce = V.current?.contains(i);
|
|
134
|
+
!d && !ce && I(!1);
|
|
125
135
|
};
|
|
126
136
|
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
127
|
-
}, [
|
|
128
|
-
const
|
|
137
|
+
}, [m]);
|
|
138
|
+
const v = !!(N && N.length > 0), ie = !u && v ? () => I((e) => !e) : M, le = !!(a || M || v);
|
|
129
139
|
return /* @__PURE__ */ l(
|
|
130
140
|
"div",
|
|
131
141
|
{
|
|
132
142
|
ref: W,
|
|
133
|
-
className:
|
|
143
|
+
className: Ce({ size: h }),
|
|
134
144
|
"data-testid": w.root,
|
|
135
|
-
"data-active":
|
|
136
|
-
"data-disabled":
|
|
145
|
+
"data-active": J,
|
|
146
|
+
"data-disabled": u,
|
|
137
147
|
children: [
|
|
138
148
|
z && /* @__PURE__ */ t(
|
|
139
149
|
"div",
|
|
@@ -146,7 +156,7 @@ const we = n.forwardRef(
|
|
|
146
156
|
type: "button",
|
|
147
157
|
onClick: z,
|
|
148
158
|
className: "flex h-5 w-5 items-center justify-center rounded-full bg-muted hover:bg-muted/80 text-muted-foreground",
|
|
149
|
-
children: /* @__PURE__ */ t(
|
|
159
|
+
children: /* @__PURE__ */ t(he, { icon: pe, className: "size-3" })
|
|
150
160
|
}
|
|
151
161
|
)
|
|
152
162
|
}
|
|
@@ -155,31 +165,54 @@ const we = n.forwardRef(
|
|
|
155
165
|
/* @__PURE__ */ t(
|
|
156
166
|
"span",
|
|
157
167
|
{
|
|
158
|
-
className:
|
|
159
|
-
|
|
168
|
+
className: y(
|
|
169
|
+
ke({ size: h }),
|
|
160
170
|
"grow shrink-0 basis-0"
|
|
161
171
|
),
|
|
162
172
|
"data-testid": w.label,
|
|
163
|
-
children:
|
|
173
|
+
children: f ?? /* @__PURE__ */ t(B, { messageId: "components.smartNumberInput.amountLabel" })
|
|
164
174
|
}
|
|
165
175
|
),
|
|
166
|
-
|
|
167
|
-
|
|
176
|
+
c !== void 0 ? /* @__PURE__ */ l("div", { className: "ml-auto flex w-1/2 min-w-0 items-center gap-1", children: [
|
|
177
|
+
/* @__PURE__ */ t("span", { className: "shrink-0 text-xs text-secondary-foreground", children: "HF" }),
|
|
178
|
+
/* @__PURE__ */ t("div", { className: "min-w-0 flex-1 [&>div]:px-0 [&>div]:pb-0", children: /* @__PURE__ */ t(
|
|
179
|
+
ge,
|
|
180
|
+
{
|
|
181
|
+
from: C(Z),
|
|
182
|
+
to: C(_),
|
|
183
|
+
value: C(c.value),
|
|
184
|
+
precision: ee,
|
|
185
|
+
markerStep: 0,
|
|
186
|
+
epsilon: 0,
|
|
187
|
+
onChangeValue: (e) => c.onChange(ze(e))
|
|
188
|
+
}
|
|
189
|
+
) }),
|
|
190
|
+
/* @__PURE__ */ t(
|
|
191
|
+
fe,
|
|
192
|
+
{
|
|
193
|
+
value: Math.round(c.value * 1e4),
|
|
194
|
+
debt: 1n,
|
|
195
|
+
decimals: 2,
|
|
196
|
+
className: "shrink-0 text-xs tabular-nums"
|
|
197
|
+
}
|
|
198
|
+
)
|
|
199
|
+
] }) : o !== void 0 && a && /* @__PURE__ */ t(
|
|
200
|
+
Ie,
|
|
168
201
|
{
|
|
169
|
-
title:
|
|
170
|
-
token:
|
|
171
|
-
maxAmount:
|
|
172
|
-
size:
|
|
173
|
-
disabled:
|
|
174
|
-
maxButton:
|
|
175
|
-
onMaxButtonClick:
|
|
202
|
+
title: x,
|
|
203
|
+
token: a,
|
|
204
|
+
maxAmount: o,
|
|
205
|
+
size: h,
|
|
206
|
+
disabled: u,
|
|
207
|
+
maxButton: R,
|
|
208
|
+
onMaxButtonClick: G
|
|
176
209
|
}
|
|
177
210
|
)
|
|
178
211
|
] }),
|
|
179
212
|
/* @__PURE__ */ l(
|
|
180
213
|
"div",
|
|
181
214
|
{
|
|
182
|
-
className:
|
|
215
|
+
className: y(
|
|
183
216
|
"flex w-full max-w-full shrink-0 basis-full items-center"
|
|
184
217
|
),
|
|
185
218
|
children: [
|
|
@@ -193,14 +226,14 @@ const we = n.forwardRef(
|
|
|
193
226
|
spellCheck: "false",
|
|
194
227
|
pattern: "^[0-9]*[.,]?[0-9]*$",
|
|
195
228
|
placeholder: "0",
|
|
196
|
-
value:
|
|
197
|
-
onChange:
|
|
198
|
-
onFocus:
|
|
199
|
-
onBlur:
|
|
200
|
-
disabled:
|
|
201
|
-
className:
|
|
202
|
-
|
|
203
|
-
|
|
229
|
+
value: s,
|
|
230
|
+
onChange: q,
|
|
231
|
+
onFocus: K,
|
|
232
|
+
onBlur: Q,
|
|
233
|
+
disabled: u || !p,
|
|
234
|
+
className: y(
|
|
235
|
+
Me({ size: h }),
|
|
236
|
+
u && "cursor-not-allowed"
|
|
204
237
|
),
|
|
205
238
|
"data-testid": w.input,
|
|
206
239
|
minLength: 1,
|
|
@@ -210,39 +243,39 @@ const we = n.forwardRef(
|
|
|
210
243
|
})
|
|
211
244
|
}
|
|
212
245
|
) }),
|
|
213
|
-
|
|
246
|
+
le ? /* @__PURE__ */ l("div", { ref: b, className: "shrink-0", children: [
|
|
214
247
|
/* @__PURE__ */ t(
|
|
215
|
-
|
|
248
|
+
me,
|
|
216
249
|
{
|
|
217
|
-
active:
|
|
218
|
-
size:
|
|
219
|
-
disabled:
|
|
220
|
-
token:
|
|
221
|
-
showSelectDialog:
|
|
222
|
-
chainId:
|
|
223
|
-
network:
|
|
224
|
-
maxLength:
|
|
225
|
-
children:
|
|
250
|
+
active: v ? m : D,
|
|
251
|
+
size: h,
|
|
252
|
+
disabled: u,
|
|
253
|
+
token: a,
|
|
254
|
+
showSelectDialog: ie,
|
|
255
|
+
chainId: S,
|
|
256
|
+
network: E,
|
|
257
|
+
maxLength: se,
|
|
258
|
+
children: a?.symbol ?? /* @__PURE__ */ t(B, { messageId: "components.smartNumberInput.selectToken" })
|
|
226
259
|
}
|
|
227
260
|
),
|
|
228
|
-
|
|
261
|
+
v && m && de(
|
|
229
262
|
/* @__PURE__ */ t(
|
|
230
263
|
"div",
|
|
231
264
|
{
|
|
232
|
-
ref:
|
|
233
|
-
style:
|
|
265
|
+
ref: V,
|
|
266
|
+
style: ae,
|
|
234
267
|
className: "overflow-hidden rounded-lg border border-gray-30 bg-gray-20 shadow-lg",
|
|
235
|
-
children:
|
|
236
|
-
const
|
|
237
|
-
return
|
|
268
|
+
children: N?.map((e, n) => {
|
|
269
|
+
const i = `${X}-${n}`, d = "flex w-full min-w-0 items-center gap-2 px-3 py-2 text-sm text-foreground hover:bg-gray-30";
|
|
270
|
+
return H ? /* @__PURE__ */ l(
|
|
238
271
|
"div",
|
|
239
272
|
{
|
|
240
|
-
className:
|
|
273
|
+
className: d,
|
|
241
274
|
children: [
|
|
242
275
|
/* @__PURE__ */ t(
|
|
243
|
-
|
|
276
|
+
ue,
|
|
244
277
|
{
|
|
245
|
-
id:
|
|
278
|
+
id: i,
|
|
246
279
|
checked: !!e.checked,
|
|
247
280
|
color: "secondary",
|
|
248
281
|
size: "md",
|
|
@@ -253,7 +286,7 @@ const we = n.forwardRef(
|
|
|
253
286
|
/* @__PURE__ */ l(
|
|
254
287
|
"label",
|
|
255
288
|
{
|
|
256
|
-
htmlFor:
|
|
289
|
+
htmlFor: i,
|
|
257
290
|
className: "flex min-w-0 flex-1 cursor-pointer items-center gap-2 text-left",
|
|
258
291
|
children: [
|
|
259
292
|
e.icon ? /* @__PURE__ */ t("span", { className: "inline-flex shrink-0 items-center", children: e.icon }) : null,
|
|
@@ -263,21 +296,21 @@ const we = n.forwardRef(
|
|
|
263
296
|
)
|
|
264
297
|
]
|
|
265
298
|
},
|
|
266
|
-
|
|
299
|
+
n
|
|
267
300
|
) : /* @__PURE__ */ l(
|
|
268
301
|
"button",
|
|
269
302
|
{
|
|
270
303
|
type: "button",
|
|
271
304
|
onClick: () => {
|
|
272
|
-
e.onSelect(),
|
|
305
|
+
e.onSelect(), I(!1);
|
|
273
306
|
},
|
|
274
|
-
className:
|
|
307
|
+
className: y(d, "text-left"),
|
|
275
308
|
children: [
|
|
276
309
|
e.icon ? /* @__PURE__ */ t("span", { className: "inline-flex shrink-0 items-center", children: e.icon }) : null,
|
|
277
310
|
/* @__PURE__ */ t("span", { className: "truncate", children: e.label })
|
|
278
311
|
]
|
|
279
312
|
},
|
|
280
|
-
|
|
313
|
+
n
|
|
281
314
|
);
|
|
282
315
|
})
|
|
283
316
|
}
|
|
@@ -288,13 +321,13 @@ const we = n.forwardRef(
|
|
|
288
321
|
]
|
|
289
322
|
}
|
|
290
323
|
),
|
|
291
|
-
|
|
324
|
+
F !== void 0 && /* @__PURE__ */ t("div", { className: "mt-1 text-xs leading-[130%] text-secondary-foreground", children: Fe(s, F) })
|
|
292
325
|
]
|
|
293
326
|
}
|
|
294
327
|
);
|
|
295
328
|
}
|
|
296
329
|
);
|
|
297
|
-
|
|
330
|
+
Le.displayName = "SmartNumberInput";
|
|
298
331
|
export {
|
|
299
|
-
|
|
332
|
+
Le as SmartNumberInput
|
|
300
333
|
};
|