@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.
@@ -1,23 +1,23 @@
1
- const g = (o, n, t) => {
2
- if (t === void 0) return o;
3
- const e = Math.max(0, Math.min(n, t)), r = n - e;
4
- return o / 10n ** BigInt(r) * 10n ** BigInt(r);
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(o) {
6
+ function i(e) {
7
7
  const n = /\.0*$|(\.\d*[1-9])0+$/gm;
8
- return o.replace(n, "$1");
8
+ return e.replace(n, "$1");
9
9
  }
10
- function s(o, n) {
11
- const t = o.toString(), e = t.length;
12
- if (e <= n)
13
- return `0.${"0".repeat(n - e)}${t}`;
14
- const r = e - n, c = t.slice(0, r), u = t.slice(r, e);
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 p(o, n, t = !1, e) {
18
- const r = g(o, n, e);
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
- p as bnToInputView
22
+ g as bnToInputView
23
23
  };
@@ -1,83 +1,84 @@
1
1
  import { generateId as r, useFormFieldIds as t } from "./a11y.js";
2
- import { bnToInputView as a } from "./bn-to-input-view.js";
3
- import { bnToPrettyView as p } from "./bn-to-pretty-view.js";
4
- import { cn as i, cn as l } from "./cn.js";
5
- import { generateColorsFromBase as T, getCSSVariable as x, hexToRgba as c, resolveCSSColor as g } from "./colors.js";
6
- import { copyToClipboard as u } from "./copy.js";
7
- import { convertPercent as d, formatBytecodeSize as h, formatBytecodeVersion as I, formatTimestamp as N, shortenHash as C, significantTrunc as b } from "./format.js";
8
- import { formatAssetAmount as P } from "./format-asset-amount.js";
9
- import { PERCENTAGE_FACTOR as L, SLIPPAGE_DECIMALS as k, formatMoney as E, formatMoney as v, formatPercentAmount as w, percentTemplate as B, percentageTemplate as D } from "./format-money.js";
10
- import { FORMAT_CONSTANTS as R, formatNumberWithSuffix as V, formatPrice as _, getAdaptiveDecimals as O, isBelowDisplayThreshold as z, isEffectivelyZero as Z, toSignificantDigits as G } from "./format-number.js";
11
- import { slippageTemplate as W } from "./format-slippage.js";
12
- import { getNetworkIcon as j } from "./network-icons.js";
13
- import { parseInputToBN as J } from "./parse-input-to-bn.js";
14
- import { pluralize as Q, selectPluralString as U } from "./plural.js";
15
- import { getAvailableRanges as $ } from "./ranges.js";
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 ne, searchInToken as pe } from "./search-in-token.js";
19
- import { shortSHA as ie } from "./short-sha.js";
20
- import { isLongString as se, shortenString as Te } from "./shorten-string.js";
21
- import { negativeTokenTemplate as ce, tokenTemplate as ge, tokenTemplateNumber as Se, tokenTemplateString as ue } from "./templates.js";
22
- import { TTL_CONSTANTS as de, getTTLZone as he, ttlFromTimestamp as Ie, ttlLeft as Ne, ttlLeftParsed as Ce } from "./ttl.js";
23
- import { openInNewWindow as ye } from "./window.js";
24
- import { Z_INDEX as Fe } from "./z-index.js";
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
- R as FORMAT_CONSTANTS,
27
- L as PERCENTAGE_FACTOR,
28
- k as SLIPPAGE_DECIMALS,
29
- de as TTL_CONSTANTS,
30
- Fe as Z_INDEX,
31
- a as bnToInputView,
32
- p as bnToPrettyView,
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
- d as convertPercent,
35
- u as copyToClipboard,
36
- ne as createTokenSearchFilter,
37
- l as default,
38
- oe as extractTextFromLabel,
39
- P as formatAssetAmount,
40
- h as formatBytecodeSize,
41
- I as formatBytecodeVersion,
42
- E as formatMoney,
43
- v as formatMoneyAmount,
44
- V as formatNumberWithSuffix,
45
- w as formatPercentAmount,
46
- _ as formatPrice,
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
- T as generateColorsFromBase,
47
+ l as generateColorsFromBase,
49
48
  r as generateId,
50
- O as getAdaptiveDecimals,
51
- $ as getAvailableRanges,
52
- x as getCSSVariable,
53
- j as getNetworkIcon,
49
+ V as getAdaptiveDecimals,
50
+ ee as getAvailableRanges,
51
+ s as getCSSVariable,
52
+ W as getNetworkIcon,
54
53
  he as getTTLZone,
55
- c as hexToRgba,
56
- z as isBelowDisplayThreshold,
57
- Z as isEffectivelyZero,
58
- se as isLongString,
59
- ce as negativeTokenTemplate,
60
- ye as openInNewWindow,
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
- B as percentTemplate,
63
- D as percentageTemplate,
64
- Q as pluralize,
65
- g as resolveCSSColor,
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
- U as selectPluralString,
69
- re as serializeValue,
70
- ie as shortSHA,
71
- C as shortenHash,
72
- Te as shortenString,
73
- b as significantTrunc,
74
- W as slippageTemplate,
75
- G as toSignificantDigits,
76
- ge as tokenTemplate,
77
- Se as tokenTemplateNumber,
78
- ue as tokenTemplateString,
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
- Ne as ttlLeft,
81
+ be as ttlLeft,
81
82
  Ce as ttlLeftParsed,
82
83
  t as useFormFieldIds
83
84
  };
@@ -1,20 +1,111 @@
1
- function p(n, l, r = !1) {
2
- if (n == null || n === "") return [0n, ""];
3
- let t = n.replace(/,/g, ".");
4
- const e = t.split(".");
5
- if (e.length > 2 && (t = `${e[0]}.${e.slice(1).join("")}`), !(r ? /^-?[0-9]*\.?[0-9]*$/ : /^[0-9]*\.?[0-9]*$/).test(t))
6
- return [null, null];
7
- const [c, u = ""] = t.split("."), a = u.padEnd(l, "0").slice(0, l), o = `${c || "0"}${a}`;
8
- try {
9
- const s = BigInt(o);
10
- return [
11
- r && t.startsWith("-") ? -s : s,
12
- t
13
- ];
14
- } catch {
15
- return [null, null];
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
- p as parseInputToBN
106
+ I as bnToLiquidationPriceView,
107
+ T as bnToPrettyView,
108
+ b as isPositiveFloat,
109
+ F as parseInputToBN,
110
+ p as parseSmallNumber
20
111
  };