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