@gearbox-protocol/permissionless-ui 1.22.0-next.27 → 1.22.0-next.28
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/input/input.cjs +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/utils/bn-to-input-view.cjs +1 -1
- package/dist/cjs/utils/index.cjs +1 -1
- package/dist/cjs/utils/parse-input-to-bn.cjs +1 -1
- package/dist/esm/components/input/input.js +127 -39
- package/dist/esm/index.js +278 -277
- package/dist/esm/utils/bn-to-input-view.js +14 -14
- package/dist/esm/utils/index.js +70 -69
- package/dist/esm/utils/parse-input-to-bn.js +108 -17
- package/dist/globals.css +1 -1
- package/dist/types/components/input/input.d.ts +9 -3
- package/dist/types/utils/parse-input-to-bn.d.ts +14 -16
- package/package.json +1 -1
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
const
|
|
2
|
-
if (t === void 0) return
|
|
3
|
-
const
|
|
4
|
-
return
|
|
1
|
+
const f = (e, n, t) => {
|
|
2
|
+
if (t === void 0) return e;
|
|
3
|
+
const o = Math.max(0, Math.min(n, t)), r = BigInt(Math.max(n - o, 0));
|
|
4
|
+
return r === 0n ? e : e / 10n ** r * 10n ** r;
|
|
5
5
|
};
|
|
6
|
-
function i(
|
|
6
|
+
function i(e) {
|
|
7
7
|
const n = /\.0*$|(\.\d*[1-9])0+$/gm;
|
|
8
|
-
return
|
|
8
|
+
return e.replace(n, "$1");
|
|
9
9
|
}
|
|
10
|
-
function s(
|
|
11
|
-
const t =
|
|
12
|
-
if (
|
|
13
|
-
return `0.${"0".repeat(n -
|
|
14
|
-
const r =
|
|
10
|
+
function s(e, n) {
|
|
11
|
+
const t = e.toString(), o = t.length;
|
|
12
|
+
if (o <= n)
|
|
13
|
+
return `0.${"0".repeat(n - o)}${t}`;
|
|
14
|
+
const r = o - n, c = t.slice(0, r), u = t.slice(r, o);
|
|
15
15
|
return `${c}.${u}`;
|
|
16
16
|
}
|
|
17
|
-
function
|
|
18
|
-
const r =
|
|
17
|
+
function g(e, n, t = !1, o) {
|
|
18
|
+
const r = f(e, n, o);
|
|
19
19
|
return r < 0 && !t ? "" : (r < 0 && t, i(s(r, n)));
|
|
20
20
|
}
|
|
21
21
|
export {
|
|
22
|
-
|
|
22
|
+
g as bnToInputView
|
|
23
23
|
};
|
package/dist/esm/utils/index.js
CHANGED
|
@@ -1,83 +1,84 @@
|
|
|
1
1
|
import { generateId as r, useFormFieldIds as t } from "./a11y.js";
|
|
2
|
-
import { bnToInputView as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import { extractTextFromLabel as oe, serializeValue as re } from "./react.js";
|
|
2
|
+
import { bnToInputView as m } from "./bn-to-input-view.js";
|
|
3
|
+
import { cn as i, cn as p } from "./cn.js";
|
|
4
|
+
import { generateColorsFromBase as l, getCSSVariable as s, hexToRgba as T, resolveCSSColor as x } from "./colors.js";
|
|
5
|
+
import { copyToClipboard as g } from "./copy.js";
|
|
6
|
+
import { convertPercent as u, formatBytecodeSize as A, formatBytecodeVersion as d, formatTimestamp as N, shortenHash as h, significantTrunc as I } from "./format.js";
|
|
7
|
+
import { formatAssetAmount as C } from "./format-asset-amount.js";
|
|
8
|
+
import { PERCENTAGE_FACTOR as F, SLIPPAGE_DECIMALS as L, formatMoney as y, formatMoney as k, formatPercentAmount as v, percentTemplate as E, percentageTemplate as w } from "./format-money.js";
|
|
9
|
+
import { FORMAT_CONSTANTS as D, formatNumberWithSuffix as M, formatPrice as R, getAdaptiveDecimals as V, isBelowDisplayThreshold as _, isEffectivelyZero as O, toSignificantDigits as z } from "./format-number.js";
|
|
10
|
+
import { slippageTemplate as G } from "./format-slippage.js";
|
|
11
|
+
import { getNetworkIcon as W } from "./network-icons.js";
|
|
12
|
+
import { bnToLiquidationPriceView as X, isPositiveFloat as j, parseInputToBN as J, parseSmallNumber as K } from "./parse-input-to-bn.js";
|
|
13
|
+
import { pluralize as U, selectPluralString as Y } from "./plural.js";
|
|
14
|
+
import { getAvailableRanges as ee } from "./ranges.js";
|
|
15
|
+
import { extractTextFromLabel as re, serializeValue as te } from "./react.js";
|
|
17
16
|
import { searchInString as me } from "./search.js";
|
|
18
|
-
import { createTokenSearchFilter as
|
|
19
|
-
import { shortSHA as
|
|
20
|
-
import { isLongString as
|
|
21
|
-
import { negativeTokenTemplate as
|
|
22
|
-
import { TTL_CONSTANTS as
|
|
23
|
-
import { openInNewWindow as
|
|
24
|
-
import { Z_INDEX as
|
|
17
|
+
import { createTokenSearchFilter as ie, searchInToken as pe } from "./search-in-token.js";
|
|
18
|
+
import { shortSHA as le } from "./short-sha.js";
|
|
19
|
+
import { isLongString as Te, shortenString as xe } from "./shorten-string.js";
|
|
20
|
+
import { negativeTokenTemplate as ge, tokenTemplate as Se, tokenTemplateNumber as ue, tokenTemplateString as Ae } from "./templates.js";
|
|
21
|
+
import { TTL_CONSTANTS as Ne, getTTLZone as he, ttlFromTimestamp as Ie, ttlLeft as be, ttlLeftParsed as Ce } from "./ttl.js";
|
|
22
|
+
import { openInNewWindow as Fe } from "./window.js";
|
|
23
|
+
import { Z_INDEX as ye } from "./z-index.js";
|
|
25
24
|
export {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
25
|
+
D as FORMAT_CONSTANTS,
|
|
26
|
+
F as PERCENTAGE_FACTOR,
|
|
27
|
+
L as SLIPPAGE_DECIMALS,
|
|
28
|
+
Ne as TTL_CONSTANTS,
|
|
29
|
+
ye as Z_INDEX,
|
|
30
|
+
m as bnToInputView,
|
|
31
|
+
X as bnToLiquidationPriceView,
|
|
33
32
|
i as cn,
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
33
|
+
u as convertPercent,
|
|
34
|
+
g as copyToClipboard,
|
|
35
|
+
ie as createTokenSearchFilter,
|
|
36
|
+
p as default,
|
|
37
|
+
re as extractTextFromLabel,
|
|
38
|
+
C as formatAssetAmount,
|
|
39
|
+
A as formatBytecodeSize,
|
|
40
|
+
d as formatBytecodeVersion,
|
|
41
|
+
y as formatMoney,
|
|
42
|
+
k as formatMoneyAmount,
|
|
43
|
+
M as formatNumberWithSuffix,
|
|
44
|
+
v as formatPercentAmount,
|
|
45
|
+
R as formatPrice,
|
|
47
46
|
N as formatTimestamp,
|
|
48
|
-
|
|
47
|
+
l as generateColorsFromBase,
|
|
49
48
|
r as generateId,
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
49
|
+
V as getAdaptiveDecimals,
|
|
50
|
+
ee as getAvailableRanges,
|
|
51
|
+
s as getCSSVariable,
|
|
52
|
+
W as getNetworkIcon,
|
|
54
53
|
he as getTTLZone,
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
54
|
+
T as hexToRgba,
|
|
55
|
+
_ as isBelowDisplayThreshold,
|
|
56
|
+
O as isEffectivelyZero,
|
|
57
|
+
Te as isLongString,
|
|
58
|
+
j as isPositiveFloat,
|
|
59
|
+
ge as negativeTokenTemplate,
|
|
60
|
+
Fe as openInNewWindow,
|
|
61
61
|
J as parseInputToBN,
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
62
|
+
K as parseSmallNumber,
|
|
63
|
+
E as percentTemplate,
|
|
64
|
+
w as percentageTemplate,
|
|
65
|
+
U as pluralize,
|
|
66
|
+
x as resolveCSSColor,
|
|
66
67
|
me as searchInString,
|
|
67
68
|
pe as searchInToken,
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
69
|
+
Y as selectPluralString,
|
|
70
|
+
te as serializeValue,
|
|
71
|
+
le as shortSHA,
|
|
72
|
+
h as shortenHash,
|
|
73
|
+
xe as shortenString,
|
|
74
|
+
I as significantTrunc,
|
|
75
|
+
G as slippageTemplate,
|
|
76
|
+
z as toSignificantDigits,
|
|
77
|
+
Se as tokenTemplate,
|
|
78
|
+
ue as tokenTemplateNumber,
|
|
79
|
+
Ae as tokenTemplateString,
|
|
79
80
|
Ie as ttlFromTimestamp,
|
|
80
|
-
|
|
81
|
+
be as ttlLeft,
|
|
81
82
|
Ce as ttlLeftParsed,
|
|
82
83
|
t as useFormFieldIds
|
|
83
84
|
};
|
|
@@ -1,20 +1,111 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
return [
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
import { toBN as g, formatBN as N } from "@gearbox-protocol/sdk";
|
|
2
|
+
import { bnToInputView as d } from "./bn-to-input-view.js";
|
|
3
|
+
function b(t) {
|
|
4
|
+
if (!/^\d+(?:[.,]\d*?)?$/.test(t)) return !1;
|
|
5
|
+
const n = parseFloat(t);
|
|
6
|
+
return !Number.isNaN(n);
|
|
7
|
+
}
|
|
8
|
+
const F = (t, e, n = !1) => {
|
|
9
|
+
if (t.length === 0 || t === "NaN")
|
|
10
|
+
return [0n, ""];
|
|
11
|
+
const i = h(t), [r, a, o] = x(i), [u, c] = A(
|
|
12
|
+
n ? o : i
|
|
13
|
+
), s = n && a ? u || "0" : u;
|
|
14
|
+
if (!b(s)) return [null, null];
|
|
15
|
+
const l = D(c), f = V(l, e);
|
|
16
|
+
return [
|
|
17
|
+
n ? g(s, e) * r : g(s, e),
|
|
18
|
+
n ? `${a}${f}` : f
|
|
19
|
+
];
|
|
20
|
+
};
|
|
21
|
+
function h(t) {
|
|
22
|
+
return t.replaceAll(",", ".");
|
|
23
|
+
}
|
|
24
|
+
function x(t) {
|
|
25
|
+
const e = t.startsWith("-");
|
|
26
|
+
return [
|
|
27
|
+
e ? -1n : 1n,
|
|
28
|
+
e ? "-" : "",
|
|
29
|
+
e ? t.slice(1) : t
|
|
30
|
+
];
|
|
31
|
+
}
|
|
32
|
+
function A(t) {
|
|
33
|
+
const e = t.startsWith("."), n = t.endsWith("."), i = `${e ? 0 : ""}${t}${n ? 0 : ""}`, r = `${e ? 0 : ""}${t}`;
|
|
34
|
+
return [i, r];
|
|
35
|
+
}
|
|
36
|
+
function D(t) {
|
|
37
|
+
const e = /^0+(0[.]|0$|[^a-zA-Z.0])/gm;
|
|
38
|
+
return t.replace(e, "$1");
|
|
39
|
+
}
|
|
40
|
+
function V(t, e) {
|
|
41
|
+
const n = t.indexOf(".");
|
|
42
|
+
if (n < 0) return t;
|
|
43
|
+
const i = t.slice(0, n), r = t.slice(n + 1);
|
|
44
|
+
return r.length <= e ? t : `${i}.${r.slice(0, e)}`;
|
|
45
|
+
}
|
|
46
|
+
function p(t) {
|
|
47
|
+
if (!t || typeof t != "string")
|
|
48
|
+
return { originalValue: t };
|
|
49
|
+
const e = t.replace(",", ".");
|
|
50
|
+
if (!/^\d*\.?\d*$/.test(e))
|
|
51
|
+
return { originalValue: t };
|
|
52
|
+
const i = parseFloat(e);
|
|
53
|
+
if (Number.isNaN(i) || i >= 1)
|
|
54
|
+
return { originalValue: t };
|
|
55
|
+
const r = e.split("."), a = r[0] || "0", o = r[1] || "", u = a.replace(/^0+/, "") || "0";
|
|
56
|
+
let c = -1;
|
|
57
|
+
for (let l = 0; l < o.length; l++)
|
|
58
|
+
if (o[l] !== "0") {
|
|
59
|
+
c = l;
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
if (c === -1)
|
|
63
|
+
return {
|
|
64
|
+
integer: u,
|
|
65
|
+
repeat: 0,
|
|
66
|
+
decimal: void 0
|
|
67
|
+
};
|
|
68
|
+
let s = o.slice(c);
|
|
69
|
+
return s = s.replace(/0+$/, ""), {
|
|
70
|
+
integer: u,
|
|
71
|
+
repeat: c,
|
|
72
|
+
decimal: s
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
function T(t, e, n, i = !1) {
|
|
76
|
+
if (t === void 0)
|
|
77
|
+
return { originalValue: "-" };
|
|
78
|
+
const r = BigInt(t), a = d(r, e, i, e), o = Number(a);
|
|
79
|
+
return Number.isNaN(o) || Math.abs(o) >= 1 || o === 0 || r <= 10n ? {
|
|
80
|
+
originalValue: N(t, e, n)
|
|
81
|
+
} : p(a);
|
|
82
|
+
}
|
|
83
|
+
const m = {
|
|
84
|
+
minimumFractionDigits: 2,
|
|
85
|
+
maximumFractionDigits: 2,
|
|
86
|
+
maxExponentialThreshold: 1e6,
|
|
87
|
+
locale: "en-US"
|
|
88
|
+
};
|
|
89
|
+
function I(t, e) {
|
|
90
|
+
const r = d(
|
|
91
|
+
t,
|
|
92
|
+
8,
|
|
93
|
+
!1,
|
|
94
|
+
8
|
|
95
|
+
), a = Number(r), o = Math.abs(Number(r));
|
|
96
|
+
return o > m.maxExponentialThreshold ? {
|
|
97
|
+
originalValue: N(t, 8, e)
|
|
98
|
+
} : Number.isNaN(a) || Math.abs(o) >= 1 ? {
|
|
99
|
+
originalValue: a.toLocaleString(m.locale, {
|
|
100
|
+
minimumFractionDigits: m.minimumFractionDigits,
|
|
101
|
+
maximumFractionDigits: m.maximumFractionDigits
|
|
102
|
+
})
|
|
103
|
+
} : p(r);
|
|
17
104
|
}
|
|
18
105
|
export {
|
|
19
|
-
|
|
106
|
+
I as bnToLiquidationPriceView,
|
|
107
|
+
T as bnToPrettyView,
|
|
108
|
+
b as isPositiveFloat,
|
|
109
|
+
F as parseInputToBN,
|
|
110
|
+
p as parseSmallNumber
|
|
20
111
|
};
|