@gearbox-protocol/permissionless-ui 1.22.0-next.37 → 1.22.0-next.39
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/colored-text/colored-text.cjs +1 -1
- package/dist/cjs/components/health-factor/health-factor.cjs +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/utils/format-money.cjs +1 -1
- package/dist/cjs/utils/index.cjs +1 -1
- package/dist/esm/components/colored-text/colored-text.js +6 -6
- package/dist/esm/components/health-factor/health-factor.js +6 -6
- package/dist/esm/index.js +154 -156
- package/dist/esm/utils/format-money.js +68 -40
- package/dist/esm/utils/index.js +65 -67
- package/dist/types/index.d.ts +1 -1
- package/dist/types/utils/format-money.d.ts +21 -24
- package/dist/types/utils/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1,48 +1,76 @@
|
|
|
1
|
-
import { BigIntMath as
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { BigIntMath as M, formatBN as A, WAD_DECIMALS_POW as $, PERCENTAGE_FACTOR as g } from "@gearbox-protocol/sdk";
|
|
2
|
+
import "react";
|
|
3
|
+
import { bnToInputView as h } from "./bn-to-input-view.js";
|
|
4
|
+
import "clsx";
|
|
5
|
+
import "tailwind-merge";
|
|
6
|
+
import "sonner";
|
|
7
|
+
import "react/jsx-runtime";
|
|
8
|
+
const _ = 10000000000000000n;
|
|
9
|
+
function F(t) {
|
|
4
10
|
return BigInt(t.toFixed(18).replace(".", ""));
|
|
5
11
|
}
|
|
6
|
-
function
|
|
7
|
-
const
|
|
8
|
-
return u ? `< ${
|
|
12
|
+
function R(t, r) {
|
|
13
|
+
const n = typeof t == "number" && t < 0 || typeof t == "bigint" && t < 0n ? "-" : "", s = typeof t == "number" ? F(Math.abs(t)) : M.abs(t), u = s < _ && s > 0n, f = u ? "0.01" : A(s, $, r), o = `${n}$${f}`;
|
|
14
|
+
return u ? `< ${o}` : o;
|
|
9
15
|
}
|
|
10
|
-
const
|
|
11
|
-
function
|
|
12
|
-
const
|
|
13
|
-
return Number.isNaN(
|
|
16
|
+
const O = 1e4;
|
|
17
|
+
function p(t, r, i = !0) {
|
|
18
|
+
const n = typeof t == "number" ? t : Number(t);
|
|
19
|
+
return Number.isNaN(n) || n === void 0 || n === null ? "0" : n === 0 ? 0 : i && n > O ? n.toExponential(r) : n.toFixed(r);
|
|
14
20
|
}
|
|
15
|
-
function
|
|
16
|
-
return `${
|
|
21
|
+
function y(t, r = 2) {
|
|
22
|
+
return `${p(t, r)}%`;
|
|
17
23
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
return `${m(n, e)}%`;
|
|
22
|
-
}
|
|
23
|
-
const A = 1000n;
|
|
24
|
-
function S(t, e) {
|
|
25
|
-
let n;
|
|
26
|
-
return typeof t == "string" ? n = Number.parseFloat(t) || 0 : typeof t == "bigint" ? n = Number(t) : n = t, typeof e == "number" ? new Intl.NumberFormat("en-US", {
|
|
27
|
-
style: "currency",
|
|
28
|
-
currency: "USD",
|
|
29
|
-
minimumFractionDigits: e,
|
|
30
|
-
maximumFractionDigits: e
|
|
31
|
-
}).format(n) : e && typeof e == "object" ? new Intl.NumberFormat("en-US", {
|
|
32
|
-
style: "currency",
|
|
33
|
-
currency: "USD",
|
|
34
|
-
...e
|
|
35
|
-
}).format(n) : new Intl.NumberFormat("en-US", {
|
|
36
|
-
style: "currency",
|
|
37
|
-
currency: "USD"
|
|
38
|
-
}).format(n);
|
|
24
|
+
function H(t, r = 2) {
|
|
25
|
+
const i = Number(t) / Number(g);
|
|
26
|
+
return `${p(i, r)}%`;
|
|
39
27
|
}
|
|
28
|
+
const c = {
|
|
29
|
+
minimumFractionDigits: 2,
|
|
30
|
+
maximumFractionDigits: 2,
|
|
31
|
+
decimalPrecision: 4,
|
|
32
|
+
minDecimalThreshold: 1,
|
|
33
|
+
minExponentialThreshold: 1e-4,
|
|
34
|
+
maxExponentialThreshold: 1e6,
|
|
35
|
+
locale: "en-US"
|
|
36
|
+
}, U = ({
|
|
37
|
+
amount: t,
|
|
38
|
+
format: r = "full",
|
|
39
|
+
maximumFractionDigits: i = c.maximumFractionDigits,
|
|
40
|
+
minimumFractionDigits: n = c.minimumFractionDigits,
|
|
41
|
+
decimalPrecision: s = c.decimalPrecision,
|
|
42
|
+
minDecimalThreshold: u = c.minDecimalThreshold,
|
|
43
|
+
minExponentialThreshold: f = c.minExponentialThreshold,
|
|
44
|
+
maxExponentialThreshold: o = c.maxExponentialThreshold,
|
|
45
|
+
locale: N = c.locale
|
|
46
|
+
}) => {
|
|
47
|
+
const m = typeof t == "bigint" ? Number(h(t, 8)) : t, e = Math.abs(m);
|
|
48
|
+
if (r === "short") {
|
|
49
|
+
const T = m < 0 ? "-" : "", a = (l, d) => {
|
|
50
|
+
const b = l >= 100 ? 0 : i, E = l.toFixed(b).replace(/(\.\d*?)0+$/, "$1").replace(/\.$/, "");
|
|
51
|
+
return `${T}${E}${d}`;
|
|
52
|
+
};
|
|
53
|
+
if (e >= 1e9 && e <= o)
|
|
54
|
+
return a(e / 1e9, "B");
|
|
55
|
+
if (e >= 1e6 && e <= o)
|
|
56
|
+
return a(e / 1e6, "M");
|
|
57
|
+
if (e >= 1e3 && e <= o)
|
|
58
|
+
return a(e / 1e3, "K");
|
|
59
|
+
if (e > o)
|
|
60
|
+
return a(e / o, "M+");
|
|
61
|
+
}
|
|
62
|
+
return e > o && r === "full" ? (m / c.maxExponentialThreshold).toFixed(
|
|
63
|
+
n
|
|
64
|
+
) + "M" : e < f && e > 0 ? m.toFixed(Math.max(10, i)) : e < u && e > 0 ? m.toPrecision(s) : m.toLocaleString(N, {
|
|
65
|
+
minimumFractionDigits: n,
|
|
66
|
+
maximumFractionDigits: i
|
|
67
|
+
});
|
|
68
|
+
};
|
|
40
69
|
export {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
T as percentageTemplate
|
|
70
|
+
c as DEFAULT_FORMAT_MONEY_CONSTANTS,
|
|
71
|
+
R as formatMoney,
|
|
72
|
+
U as formatMoneyAmount,
|
|
73
|
+
p as formatPercentAmount,
|
|
74
|
+
y as percentTemplate,
|
|
75
|
+
H as percentageTemplate
|
|
48
76
|
};
|
package/dist/esm/utils/index.js
CHANGED
|
@@ -4,87 +4,85 @@ import { bnToPrettyView as i } from "./bn-to-pretty-view.js";
|
|
|
4
4
|
import { cn as f, cn as l } from "./cn.js";
|
|
5
5
|
import { generateColorsFromBase as T, getCSSVariable as x, hexToRgba as c, resolveCSSColor as g } from "./colors.js";
|
|
6
6
|
import { copyToClipboard as u } from "./copy.js";
|
|
7
|
-
import { convertPercent as
|
|
8
|
-
import { formatAssetAmount as
|
|
9
|
-
import {
|
|
10
|
-
import { FORMAT_CONSTANTS as
|
|
11
|
-
import { slippageTemplate as
|
|
12
|
-
import { allLoaded as
|
|
13
|
-
import { getNetworkIcon as
|
|
14
|
-
import { bnToLiquidationPriceView as
|
|
15
|
-
import { pluralize as
|
|
16
|
-
import { getAvailableRanges as
|
|
17
|
-
import { extractTextFromLabel as
|
|
18
|
-
import { searchInString as
|
|
19
|
-
import { createTokenSearchFilter as
|
|
20
|
-
import { shortSHA as
|
|
21
|
-
import { isLongString as
|
|
22
|
-
import { negativeTokenTemplate as
|
|
23
|
-
import { TTL_CONSTANTS as
|
|
24
|
-
import { openInNewWindow as
|
|
25
|
-
import { Z_INDEX as
|
|
7
|
+
import { convertPercent as b, formatBytecodeSize as h, formatBytecodeVersion as N, formatTimestamp as A, shortenHash as I, significantTrunc as P } from "./format.js";
|
|
8
|
+
import { formatAssetAmount as F } from "./format-asset-amount.js";
|
|
9
|
+
import { formatMoney as k, formatMoneyAmount as v, formatPercentAmount as w, percentTemplate as C, percentageTemplate as V } from "./format-money.js";
|
|
10
|
+
import { FORMAT_CONSTANTS as D, formatNumberWithSuffix as z, formatPrice as M, getAdaptiveDecimals as O, isBelowDisplayThreshold as R, isEffectivelyZero as Z, toSignificantDigits as _ } from "./format-number.js";
|
|
11
|
+
import { slippageTemplate as H } from "./format-slippage.js";
|
|
12
|
+
import { allLoaded as q, loadingProgress as X, round5 as j } from "./loading.js";
|
|
13
|
+
import { getNetworkIcon as J } from "./network-icons.js";
|
|
14
|
+
import { bnToLiquidationPriceView as Q, isPositiveFloat as U, parseInputToBN as Y, parseSmallNumber as $ } from "./parse-input-to-bn.js";
|
|
15
|
+
import { pluralize as oe, selectPluralString as re } from "./plural.js";
|
|
16
|
+
import { getAvailableRanges as ae } from "./ranges.js";
|
|
17
|
+
import { extractTextFromLabel as ne, serializeValue as ie } from "./react.js";
|
|
18
|
+
import { searchInString as fe } from "./search.js";
|
|
19
|
+
import { createTokenSearchFilter as se, searchInToken as Te } from "./search-in-token.js";
|
|
20
|
+
import { shortSHA as ce } from "./short-sha.js";
|
|
21
|
+
import { isLongString as Se, shortenString as ue } from "./shorten-string.js";
|
|
22
|
+
import { negativeTokenTemplate as be, tokenTemplate as he, tokenTemplateNumber as Ne, tokenTemplateString as Ae } from "./templates.js";
|
|
23
|
+
import { TTL_CONSTANTS as Pe, getTTLZone as ye, ttlFromTimestamp as Fe, ttlLeft as Le, ttlLeftParsed as ke } from "./ttl.js";
|
|
24
|
+
import { openInNewWindow as we } from "./window.js";
|
|
25
|
+
import { Z_INDEX as Ve } from "./z-index.js";
|
|
26
26
|
export {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
Be as Z_INDEX,
|
|
32
|
-
X as allLoaded,
|
|
27
|
+
D as FORMAT_CONSTANTS,
|
|
28
|
+
Pe as TTL_CONSTANTS,
|
|
29
|
+
Ve as Z_INDEX,
|
|
30
|
+
q as allLoaded,
|
|
33
31
|
m as bnToInputView,
|
|
34
|
-
|
|
32
|
+
Q as bnToLiquidationPriceView,
|
|
35
33
|
i as bnToPrettyView,
|
|
36
34
|
f as cn,
|
|
37
|
-
|
|
35
|
+
b as convertPercent,
|
|
38
36
|
u as copyToClipboard,
|
|
39
|
-
|
|
37
|
+
se as createTokenSearchFilter,
|
|
40
38
|
l as default,
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
39
|
+
ne as extractTextFromLabel,
|
|
40
|
+
F as formatAssetAmount,
|
|
41
|
+
h as formatBytecodeSize,
|
|
42
|
+
N as formatBytecodeVersion,
|
|
43
|
+
k as formatMoney,
|
|
44
|
+
v as formatMoneyAmount,
|
|
45
|
+
z as formatNumberWithSuffix,
|
|
46
|
+
w as formatPercentAmount,
|
|
47
|
+
M as formatPrice,
|
|
48
|
+
A as formatTimestamp,
|
|
51
49
|
T as generateColorsFromBase,
|
|
52
50
|
r as generateId,
|
|
53
51
|
O as getAdaptiveDecimals,
|
|
54
|
-
|
|
52
|
+
ae as getAvailableRanges,
|
|
55
53
|
x as getCSSVariable,
|
|
56
|
-
|
|
54
|
+
J as getNetworkIcon,
|
|
57
55
|
ye as getTTLZone,
|
|
58
56
|
c as hexToRgba,
|
|
59
|
-
|
|
57
|
+
R as isBelowDisplayThreshold,
|
|
60
58
|
Z as isEffectivelyZero,
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
59
|
+
Se as isLongString,
|
|
60
|
+
U as isPositiveFloat,
|
|
61
|
+
X as loadingProgress,
|
|
62
|
+
be as negativeTokenTemplate,
|
|
63
|
+
we as openInNewWindow,
|
|
64
|
+
Y as parseInputToBN,
|
|
65
|
+
$ as parseSmallNumber,
|
|
66
|
+
C as percentTemplate,
|
|
67
|
+
V as percentageTemplate,
|
|
68
|
+
oe as pluralize,
|
|
71
69
|
g as resolveCSSColor,
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
70
|
+
j as round5,
|
|
71
|
+
fe as searchInString,
|
|
72
|
+
Te as searchInToken,
|
|
73
|
+
re as selectPluralString,
|
|
74
|
+
ie as serializeValue,
|
|
75
|
+
ce as shortSHA,
|
|
76
|
+
I as shortenHash,
|
|
77
|
+
ue as shortenString,
|
|
78
|
+
P as significantTrunc,
|
|
79
|
+
H as slippageTemplate,
|
|
80
|
+
_ as toSignificantDigits,
|
|
81
|
+
he as tokenTemplate,
|
|
82
|
+
Ne as tokenTemplateNumber,
|
|
83
|
+
Ae as tokenTemplateString,
|
|
86
84
|
Fe as ttlFromTimestamp,
|
|
87
|
-
|
|
88
|
-
|
|
85
|
+
Le as ttlLeft,
|
|
86
|
+
ke as ttlLeftParsed,
|
|
89
87
|
t as useFormFieldIds
|
|
90
88
|
};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -133,5 +133,5 @@ export * from './utils/a11y';
|
|
|
133
133
|
export { cn } from './utils/cn';
|
|
134
134
|
export * from './utils/copy';
|
|
135
135
|
export * from './utils/format';
|
|
136
|
-
export { formatMoney, formatPercentAmount,
|
|
136
|
+
export { formatMoney, formatPercentAmount, percentageTemplate, percentTemplate, } from './utils/format-money';
|
|
137
137
|
export * from './utils/templates';
|
|
@@ -44,10 +44,6 @@ export declare function formatPercentAmount(value: number, decimals: number, all
|
|
|
44
44
|
* ```
|
|
45
45
|
*/
|
|
46
46
|
export declare function percentTemplate(value: number, decimals?: number): string;
|
|
47
|
-
/**
|
|
48
|
-
* The factor used for percentage values in basis points (10000 = 100%)
|
|
49
|
-
*/
|
|
50
|
-
export declare const PERCENTAGE_FACTOR = 10000;
|
|
51
47
|
/**
|
|
52
48
|
* Formats a percentage value from basis points
|
|
53
49
|
* Use this when your value is in basis points (10000 = 100%)
|
|
@@ -64,23 +60,24 @@ export declare const PERCENTAGE_FACTOR = 10000;
|
|
|
64
60
|
* ```
|
|
65
61
|
*/
|
|
66
62
|
export declare function percentageTemplate(value: number | bigint, decimals?: number): string;
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
63
|
+
export declare const DEFAULT_FORMAT_MONEY_CONSTANTS: {
|
|
64
|
+
minimumFractionDigits: number;
|
|
65
|
+
maximumFractionDigits: number;
|
|
66
|
+
decimalPrecision: number;
|
|
67
|
+
minDecimalThreshold: number;
|
|
68
|
+
minExponentialThreshold: number;
|
|
69
|
+
maxExponentialThreshold: number;
|
|
70
|
+
locale: string;
|
|
71
|
+
};
|
|
72
|
+
export interface FormatMoneyAmountProps {
|
|
73
|
+
amount: number | bigint;
|
|
74
|
+
format?: "short" | "full";
|
|
75
|
+
maximumFractionDigits?: number;
|
|
76
|
+
minimumFractionDigits?: number;
|
|
77
|
+
decimalPrecision?: number;
|
|
78
|
+
minDecimalThreshold?: number;
|
|
79
|
+
minExponentialThreshold?: number;
|
|
80
|
+
maxExponentialThreshold?: number;
|
|
81
|
+
locale?: string;
|
|
82
|
+
}
|
|
83
|
+
export declare const formatMoneyAmount: ({ amount, format, maximumFractionDigits, minimumFractionDigits, decimalPrecision, minDecimalThreshold, minExponentialThreshold, maxExponentialThreshold, locale, }: FormatMoneyAmountProps) => string;
|
|
@@ -7,7 +7,7 @@ export * from './colors';
|
|
|
7
7
|
export * from './copy';
|
|
8
8
|
export * from './format';
|
|
9
9
|
export * from './format-asset-amount';
|
|
10
|
-
export { formatMoney,
|
|
10
|
+
export { formatMoney, formatMoneyAmount, formatPercentAmount, percentageTemplate, percentTemplate, } from './format-money';
|
|
11
11
|
export { FORMAT_CONSTANTS, type FormatNumberOptions, formatNumberWithSuffix, formatPrice, getAdaptiveDecimals, isBelowDisplayThreshold, isEffectivelyZero, toSignificantDigits, } from './format-number';
|
|
12
12
|
export * from './format-slippage';
|
|
13
13
|
export * from './interface';
|